@astrale-os/kernel-client 1.0.0-beta.13 → 1.0.0-beta.14
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.
- package/dist/errors/refusal.js +5 -1
- package/dist/session/content/retry.js +2 -17
- package/dist/session/context/index.d.ts +1 -1
- package/dist/session/context/index.js +1 -1
- package/dist/session/context/operation.d.ts +2 -0
- package/dist/session/context/operation.js +19 -0
- package/dist/session/credential/credentials.js +9 -4
- package/dist/session/durable.d.ts +13 -0
- package/dist/session/durable.js +45 -0
- package/dist/session/routing/dispatch.d.ts +20 -2
- package/dist/session/routing/dispatch.js +12 -4
- package/dist/session/session.d.ts +4 -0
- package/dist/session/session.js +12 -4
- package/dist/transport/websocket/exchange.js +5 -1
- package/package.json +5 -5
package/dist/errors/refusal.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as errors from '@astrale-os/kernel-protocol/errors';
|
|
2
2
|
import { CALLABLE_FINGERPRINT_MISMATCH } from '@astrale-os/kernel-protocol/invocation';
|
|
3
3
|
import { ResponseError } from './response-error.js';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Sealed conflicts whose plan met a checkpoint advanced past its pinned snapshot, an Authority
|
|
6
|
+
* evaluation's included (POLICY_SNAPSHOT_MISMATCH).
|
|
7
|
+
*/
|
|
5
8
|
const SNAPSHOT_STALE_REASONS = new Set([
|
|
6
9
|
'SNAPSHOT_STALE',
|
|
7
10
|
'QUERY_SNAPSHOT_STALE',
|
|
8
11
|
'MUTATION_SNAPSHOT_STALE',
|
|
12
|
+
'POLICY_SNAPSHOT_MISMATCH',
|
|
9
13
|
]);
|
|
10
14
|
/** Conflicts whose request expects a Domain meaning this Instance does not serve. */
|
|
11
15
|
const EXPECTATION_MISMATCH_REASONS = new Set([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CODES } from '@astrale-os/kernel-protocol/errors';
|
|
2
2
|
import { ResponseError, TransportError } from '../../errors/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { pauseSessionOperation } from '../context/index.js';
|
|
4
4
|
const MAXIMUM_ATTEMPTS = 3;
|
|
5
5
|
/** Repeat one content request that failed before any of its result was delivered. */
|
|
6
6
|
export async function retry(operation, request) {
|
|
@@ -12,7 +12,7 @@ export async function retry(operation, request) {
|
|
|
12
12
|
if (!retryable(cause) || attempt + 1 === MAXIMUM_ATTEMPTS || operation.signal.aborted) {
|
|
13
13
|
throw cause;
|
|
14
14
|
}
|
|
15
|
-
await
|
|
15
|
+
await pauseSessionOperation(operation, 200 * 2 ** attempt);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -24,18 +24,3 @@ function retryable(cause) {
|
|
|
24
24
|
cause.code === CODES.DEADLINE_EXCEEDED ||
|
|
25
25
|
cause.code === CODES.OUTCOME_UNKNOWN)));
|
|
26
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
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { admitControlOptions, type SessionControlOptions } from './control.js';
|
|
2
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
|
-
export { createSessionOperation, remainingSessionTime, runSessionOperation, sessionTransportOptions, type SessionOperation, } from './operation.js';
|
|
3
|
+
export { createSessionOperation, pauseSessionOperation, 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
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
|
-
export { createSessionOperation, remainingSessionTime, runSessionOperation, sessionTransportOptions, } from './operation.js';
|
|
3
|
+
export { createSessionOperation, pauseSessionOperation, remainingSessionTime, runSessionOperation, sessionTransportOptions, } from './operation.js';
|
|
4
4
|
export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, } from './policy.js';
|
|
@@ -20,3 +20,5 @@ 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
|
+
/** Wait `ms` before another attempt, ending early with the operation's interruption. */
|
|
24
|
+
export declare function pauseSessionOperation(operation: SessionOperation, ms: number): Promise<void>;
|
|
@@ -54,6 +54,25 @@ export async function runSessionOperation(operation, task) {
|
|
|
54
54
|
operation.signal.removeEventListener('abort', abort);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
/** Wait `ms` before another attempt, ending early with the operation's interruption. */
|
|
58
|
+
export function pauseSessionOperation(operation, ms) {
|
|
59
|
+
return runSessionOperation(operation, (signal) => delay(ms, signal));
|
|
60
|
+
}
|
|
61
|
+
function delay(ms, signal) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
if (signal.aborted)
|
|
64
|
+
return reject(signal.reason);
|
|
65
|
+
const timer = setTimeout(() => {
|
|
66
|
+
signal.removeEventListener('abort', abort);
|
|
67
|
+
resolve();
|
|
68
|
+
}, ms);
|
|
69
|
+
const abort = () => {
|
|
70
|
+
clearTimeout(timer);
|
|
71
|
+
reject(signal.reason);
|
|
72
|
+
};
|
|
73
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
57
76
|
function requireSessionOperation(operation) {
|
|
58
77
|
if (!operation.signal.aborted)
|
|
59
78
|
return;
|
|
@@ -38,6 +38,8 @@ export function credentials(source) {
|
|
|
38
38
|
let inflight;
|
|
39
39
|
let controller;
|
|
40
40
|
let waiting = 0;
|
|
41
|
+
/** A caller without a signal keeps the mint in flight alive; anticipation does not. */
|
|
42
|
+
let unsignalled = false;
|
|
41
43
|
let anticipating = false;
|
|
42
44
|
let refreshTimer;
|
|
43
45
|
let expiryTimer;
|
|
@@ -76,8 +78,10 @@ export function credentials(source) {
|
|
|
76
78
|
if (signal?.aborted === true)
|
|
77
79
|
return Promise.reject(signal.reason);
|
|
78
80
|
const pending = inflight ?? begin();
|
|
79
|
-
if (signal === undefined)
|
|
81
|
+
if (signal === undefined) {
|
|
82
|
+
unsignalled = true;
|
|
80
83
|
return pending;
|
|
84
|
+
}
|
|
81
85
|
waiting += 1;
|
|
82
86
|
let settled = false;
|
|
83
87
|
return new Promise((complete, fail) => {
|
|
@@ -88,7 +92,7 @@ export function credentials(source) {
|
|
|
88
92
|
waiting -= 1;
|
|
89
93
|
signal.removeEventListener('abort', cancel);
|
|
90
94
|
// Nobody is waiting and nobody is anticipating: the mint has no beneficiary left.
|
|
91
|
-
if (waiting === 0 && !anticipating)
|
|
95
|
+
if (waiting === 0 && !anticipating && !unsignalled)
|
|
92
96
|
controller?.abort(signal.reason);
|
|
93
97
|
};
|
|
94
98
|
const cancel = () => {
|
|
@@ -124,6 +128,7 @@ export function credentials(source) {
|
|
|
124
128
|
publish({ status: 'refreshing', ...(current === undefined ? {} : { credential: current }) });
|
|
125
129
|
const owned = new AbortController();
|
|
126
130
|
controller = owned;
|
|
131
|
+
unsignalled = false;
|
|
127
132
|
const signal = AbortSignal.any([owned.signal, AbortSignal.timeout(MINT_TIMEOUT_MS)]);
|
|
128
133
|
const pending = (async () => {
|
|
129
134
|
try {
|
|
@@ -166,7 +171,7 @@ export function credentials(source) {
|
|
|
166
171
|
if (!anticipating)
|
|
167
172
|
return;
|
|
168
173
|
if (current === undefined) {
|
|
169
|
-
void
|
|
174
|
+
void (inflight ?? begin()).catch(() => undefined);
|
|
170
175
|
return;
|
|
171
176
|
}
|
|
172
177
|
// The threshold itself, with no extra lead: chained providers sharing this rule must not
|
|
@@ -189,7 +194,7 @@ export function credentials(source) {
|
|
|
189
194
|
function armRefresh(delay) {
|
|
190
195
|
refreshTimer = setTimeout(() => {
|
|
191
196
|
refreshTimer = undefined;
|
|
192
|
-
void
|
|
197
|
+
void (inflight ?? begin()).catch(() => undefined);
|
|
193
198
|
}, delay);
|
|
194
199
|
}
|
|
195
200
|
function armExpiry(credential) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SessionOperation } from './context/index.js';
|
|
2
|
+
import type { SessionRequestOptions } from './routing/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options of one typed invocation of a durable callable: the caller's key, or one created for this
|
|
5
|
+
* call. The key names the Execution, so every attempt of the call reaches the same one.
|
|
6
|
+
*/
|
|
7
|
+
export declare function durableOptions(options: Readonly<SessionRequestOptions>): Readonly<SessionRequestOptions>;
|
|
8
|
+
/**
|
|
9
|
+
* Send a keyed durable invocation again while its outcome is unknown: a transport failure, sent or
|
|
10
|
+
* not, or the Kernel's `OUTCOME_UNKNOWN`. Its key makes the Kernel answer with the Execution a lost
|
|
11
|
+
* attempt recorded, marked `replayed`, instead of starting another.
|
|
12
|
+
*/
|
|
13
|
+
export declare function attemptDurable<Result>(operation: SessionOperation, attempt: () => Promise<Result>): Promise<Result>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CODES } from '@astrale-os/kernel-protocol/errors';
|
|
2
|
+
import * as invocationProtocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
|
+
import { ResponseError, TransportError } from '../errors/index.js';
|
|
4
|
+
import { pauseSessionOperation } from './context/index.js';
|
|
5
|
+
/** The first attempt of a durable invocation and at most two more, within its one deadline. */
|
|
6
|
+
const MAXIMUM_ATTEMPTS = 3;
|
|
7
|
+
const FIRST_PAUSE_MS = 200;
|
|
8
|
+
/**
|
|
9
|
+
* Options of one typed invocation of a durable callable: the caller's key, or one created for this
|
|
10
|
+
* call. The key names the Execution, so every attempt of the call reaches the same one.
|
|
11
|
+
*/
|
|
12
|
+
export function durableOptions(options) {
|
|
13
|
+
if (options.idempotencyKey !== undefined)
|
|
14
|
+
return options;
|
|
15
|
+
return Object.freeze({
|
|
16
|
+
...options,
|
|
17
|
+
idempotencyKey: invocationProtocol.acceptIdempotencyKey(crypto.randomUUID()),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Send a keyed durable invocation again while its outcome is unknown: a transport failure, sent or
|
|
22
|
+
* not, or the Kernel's `OUTCOME_UNKNOWN`. Its key makes the Kernel answer with the Execution a lost
|
|
23
|
+
* attempt recorded, marked `replayed`, instead of starting another.
|
|
24
|
+
*/
|
|
25
|
+
export async function attemptDurable(operation, attempt) {
|
|
26
|
+
for (let attempts = 1;; attempts++) {
|
|
27
|
+
try {
|
|
28
|
+
return await attempt();
|
|
29
|
+
}
|
|
30
|
+
catch (cause) {
|
|
31
|
+
const pause = FIRST_PAUSE_MS * 2 ** (attempts - 1);
|
|
32
|
+
if (attempts === MAXIMUM_ATTEMPTS ||
|
|
33
|
+
!unknownOutcome(cause) ||
|
|
34
|
+
operation.signal.aborted ||
|
|
35
|
+
operation.deadline - Date.now() <= pause) {
|
|
36
|
+
throw cause;
|
|
37
|
+
}
|
|
38
|
+
await pauseSessionOperation(operation, pause);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function unknownOutcome(cause) {
|
|
43
|
+
return ((cause instanceof TransportError && cause.context.kind === 'invocation') ||
|
|
44
|
+
(cause instanceof ResponseError && cause.code === CODES.OUTCOME_UNKNOWN));
|
|
45
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
+
import type * as invocation from '@astrale-os/kernel-protocol/invocation';
|
|
2
3
|
import type { Result } from '../../client/index.js';
|
|
3
4
|
import type { Fetch } from '../../transport/http/index.js';
|
|
4
5
|
import type { SessionOperation, SessionPolicy } from '../context/index.js';
|
|
5
|
-
import type { AuthExchange, SessionAuth } from './auth.js';
|
|
6
|
+
import type { AuthExchange, SessionAuth, EffectiveAuth } from './auth.js';
|
|
6
7
|
import type { RouteCache } from './cache.js';
|
|
7
8
|
import type { ClientPoolCapability } from './envelope.js';
|
|
8
9
|
import type { SessionEnvelopeTransport, SessionRequestOptions } from './request.js';
|
|
@@ -24,13 +25,30 @@ export interface SessionDispatcherOptions {
|
|
|
24
25
|
readonly timeoutMs: number;
|
|
25
26
|
};
|
|
26
27
|
}
|
|
28
|
+
/** A streaming call is forced over HTTP and may carry a binary body. */
|
|
29
|
+
export interface Streaming {
|
|
30
|
+
readonly body?: Blob;
|
|
31
|
+
}
|
|
32
|
+
/** One Call with the authority it presents on every dispatch, and the route partition it selects. */
|
|
33
|
+
export interface ResolvedCall {
|
|
34
|
+
readonly call: invocation.Call;
|
|
35
|
+
readonly auth: EffectiveAuth;
|
|
36
|
+
readonly source: IssuerId;
|
|
37
|
+
readonly cacheKey: string;
|
|
38
|
+
}
|
|
27
39
|
export declare class SessionDispatcher {
|
|
28
40
|
private readonly state;
|
|
29
41
|
constructor(state: SessionDispatcherOptions);
|
|
30
42
|
dispatch(input: Parameters<typeof acceptCall>[0], options: SessionRequestOptions, operation: SessionOperation): Promise<Result>;
|
|
31
43
|
/** Reuse Session authority and route recovery while forcing HTTP for streaming calls. */
|
|
32
44
|
dispatchHttp(input: Parameters<typeof acceptCall>[0], options: SessionRequestOptions, operation: SessionOperation, body?: Blob): Promise<Result>;
|
|
33
|
-
|
|
45
|
+
/** Resolve the Session authority of one Call: each dispatch of the result presents it. */
|
|
46
|
+
resolve(input: Parameters<typeof acceptCall>[0], operation: SessionOperation): Promise<ResolvedCall>;
|
|
47
|
+
/**
|
|
48
|
+
* Dispatch a resolved Call. Sending it again presents the same principal and caller, which an
|
|
49
|
+
* idempotency key needs to name the same Execution.
|
|
50
|
+
*/
|
|
51
|
+
dispatchResolved(dispatch: ResolvedCall, options: SessionRequestOptions, operation: SessionOperation, streaming?: Streaming): Promise<Result>;
|
|
34
52
|
/** The cached route for this partition, evicted when it no longer passes delivery checks. */
|
|
35
53
|
private warmRoute;
|
|
36
54
|
private dispatchSource;
|
|
@@ -11,13 +11,14 @@ export class SessionDispatcher {
|
|
|
11
11
|
this.state = state;
|
|
12
12
|
}
|
|
13
13
|
async dispatch(input, options, operation) {
|
|
14
|
-
return this.
|
|
14
|
+
return this.dispatchResolved(await this.resolve(input, operation), options, operation);
|
|
15
15
|
}
|
|
16
16
|
/** Reuse Session authority and route recovery while forcing HTTP for streaming calls. */
|
|
17
17
|
async dispatchHttp(input, options, operation, body) {
|
|
18
|
-
return this.
|
|
18
|
+
return this.dispatchResolved(await this.resolve(input, operation), options, operation, { body });
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/** Resolve the Session authority of one Call: each dispatch of the result presents it. */
|
|
21
|
+
async resolve(input, operation) {
|
|
21
22
|
this.state.requireOpen();
|
|
22
23
|
const call = acceptCall(input);
|
|
23
24
|
// Authority is resolved before warm lookup so changed credentials or delegation cannot reuse a
|
|
@@ -28,7 +29,14 @@ export class SessionDispatcher {
|
|
|
28
29
|
: await this.state.exchange.resolve(call, resolved, operation);
|
|
29
30
|
const source = this.state.kernel;
|
|
30
31
|
const cacheKey = await runSessionOperation(operation, () => this.state.cache.key(source, call, auth));
|
|
31
|
-
|
|
32
|
+
return Object.freeze({ call, auth, source, cacheKey });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Dispatch a resolved Call. Sending it again presents the same principal and caller, which an
|
|
36
|
+
* idempotency key needs to name the same Execution.
|
|
37
|
+
*/
|
|
38
|
+
async dispatchResolved(dispatch, options, operation, streaming) {
|
|
39
|
+
this.state.requireOpen();
|
|
32
40
|
const learned = await this.warmRoute(dispatch, operation, streaming);
|
|
33
41
|
if (learned !== undefined) {
|
|
34
42
|
return this.dispatchDestinationWithRecovery(learned, dispatch, options, operation, undefined, streaming);
|
|
@@ -61,6 +61,10 @@ export declare class ClientSession {
|
|
|
61
61
|
dispatch(call: Call, options: SessionRequestOptionsWithBody): Promise<Result>;
|
|
62
62
|
call(call: Call, options?: SessionRequestOptions): Promise<Input>;
|
|
63
63
|
call(call: Call, options: SessionRequestOptionsWithBody): Promise<Input>;
|
|
64
|
+
/**
|
|
65
|
+
* Invoke one typed reference. A durable callable's call is keyed, by the caller's key or by one
|
|
66
|
+
* created for this call, and sent again with that key while its outcome is unknown.
|
|
67
|
+
*/
|
|
64
68
|
invoke<const Reference extends CallableReference<unknown>>(reference: InputModeOfReference<Reference> extends 'binary' ? never : Reference, input: InputOfReference<Reference>, options?: SessionRequestOptions): Promise<OutputOfReference<Reference>>;
|
|
65
69
|
invoke<const Reference extends CallableReference<unknown, unknown, 'binary'>>(reference: Reference, input: InputOfReference<Reference>, options: SessionRequestOptionsWithBody): Promise<OutputOfReference<Reference>>;
|
|
66
70
|
private dispatchWith;
|
package/dist/session/session.js
CHANGED
|
@@ -11,6 +11,7 @@ import { admitFunction } from './admission.js';
|
|
|
11
11
|
import { createContentApi } from './content/index.js';
|
|
12
12
|
import { admitControlOptions, allowEndpoint, createSessionOperation } from './context/index.js';
|
|
13
13
|
import { createSessionDiscovery } from './discovery/index.js';
|
|
14
|
+
import { attemptDurable, durableOptions } from './durable.js';
|
|
14
15
|
import { acquireDomainCredential, admitExchangeRequest, createSessionExchange, } from './exchange/index.js';
|
|
15
16
|
import { acceptSessionOptions } from './options.js';
|
|
16
17
|
import { admitReference, outputModeOf } from './reference.js';
|
|
@@ -160,10 +161,17 @@ export class ClientSession {
|
|
|
160
161
|
}),
|
|
161
162
|
input,
|
|
162
163
|
};
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
// A durable call is keyed, so an attempt whose outcome is unknown can be sent again.
|
|
165
|
+
const durable = admittedReference.outputMode === 'execution';
|
|
166
|
+
const requested = durable ? durableOptions(admitted.options) : admitted.options;
|
|
167
|
+
const operation = this.operation(requested);
|
|
168
|
+
const streaming = admitted.body === undefined && admittedReference.outputMode !== 'binary'
|
|
169
|
+
? undefined
|
|
170
|
+
: { body: admitted.body };
|
|
171
|
+
// Resolved once: every attempt presents the principal and caller its key names an Execution with.
|
|
172
|
+
const resolved = await this.dispatcher.resolve(call, operation);
|
|
173
|
+
const attempt = () => this.dispatcher.dispatchResolved(resolved, requested, operation, streaming);
|
|
174
|
+
const result = await (durable ? attemptDurable(operation, attempt) : attempt());
|
|
167
175
|
const narrowed = requireResultKind(admittedReference.outputMode, result);
|
|
168
176
|
switch (narrowed.kind) {
|
|
169
177
|
case 'stream':
|
|
@@ -57,7 +57,7 @@ export class WebSocketExchange {
|
|
|
57
57
|
this.receiveResponse(input);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
if (this.state !== 'stream' ||
|
|
60
|
+
if (this.state !== 'stream' || !isStreamFrame(input)) {
|
|
61
61
|
throw new ProtocolError('server sent an unexpected WebSocket response.');
|
|
62
62
|
}
|
|
63
63
|
this.receiveStreamFrame(input);
|
|
@@ -301,6 +301,10 @@ function requireId(expected, received) {
|
|
|
301
301
|
throw new ProtocolError(`response requestId ${JSON.stringify(received)} does not match request requestId ${JSON.stringify(expected)}.`);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
+
/** Only stream frames may follow `stream.start`; a unary response would end the stream unchecked. */
|
|
305
|
+
function isStreamFrame(input) {
|
|
306
|
+
return 'kind' in input && typeof input.kind === 'string' && input.kind.startsWith('stream.');
|
|
307
|
+
}
|
|
304
308
|
function isKind(input, kind) {
|
|
305
309
|
return (typeof input === 'object' &&
|
|
306
310
|
input !== null &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-client",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.14",
|
|
4
4
|
"description": "Universal Client — protocol-first, transport-agnostic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@astrale-os/kernel-core": "1.0.0-beta.
|
|
69
|
-
"@astrale-os/kernel-dsl": "1.0.0-beta.
|
|
70
|
-
"@astrale-os/kernel-protocol": "1.0.0-beta.
|
|
68
|
+
"@astrale-os/kernel-core": "1.0.0-beta.12",
|
|
69
|
+
"@astrale-os/kernel-dsl": "1.0.0-beta.6",
|
|
70
|
+
"@astrale-os/kernel-protocol": "1.0.0-beta.12",
|
|
71
71
|
"@tanstack/pacer": "0.20.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@astrale-os/kernel-server": "1.0.0-beta.
|
|
74
|
+
"@astrale-os/kernel-server": "1.0.0-beta.12",
|
|
75
75
|
"@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
|
|
76
76
|
"@types/node": "^22.0.0",
|
|
77
77
|
"typescript": "7.0.2",
|