@kinotic-ai/core 5.0.0-beta.3 → 5.0.0-beta.31

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/index.d.cts CHANGED
@@ -54,6 +54,11 @@ type WebSocketFactory = () => IWebSocket | Promise<IWebSocket>;
54
54
  declare class ServerInfo {
55
55
  host: string;
56
56
  port?: number | null;
57
+ /**
58
+ * Whether the server is reached over TLS. Absent, {@code KINOTIC_SERVER_USE_SSL} decides,
59
+ * then the page's own protocol for a host taken from the browser's location, and otherwise
60
+ * TLS for every host but a loopback one ({@code localhost}, {@code 127.0.0.1}, {@code ::1}).
61
+ */
57
62
  useSSL?: boolean | null;
58
63
  }
59
64
  /**
@@ -76,7 +81,7 @@ declare enum SessionKeepAliveMode {
76
81
  * Options for {@link IKinotic#connect}. Every field is optional: absent {@link server}
77
82
  * fields resolve from the environment (the {@code KINOTIC_SERVER_HOST} /
78
83
  * {@code KINOTIC_SERVER_PORT} / {@code KINOTIC_SERVER_USE_SSL} variables, the browser's own
79
- * location, then {@code https://api.kinotic.com}), and absent {@link credentials} resolve
84
+ * location, then {@code https://api.kinotic.ai}), and absent {@link credentials} resolve
80
85
  * through the default {@link ChainedCredentialsResolver} (environment variables, then the
81
86
  * browser session).
82
87
  *
@@ -98,8 +103,10 @@ interface ConnectOptions {
98
103
  */
99
104
  webSocketFactory?: WebSocketFactory;
100
105
  /**
101
- * The maximum number of connection attempts to make during the {@link IEventBus} initial connection request.
102
- * If the limit is reached the {@link IEventBus} will return an error to the caller of {@link IEventBus#connect}
106
+ * The maximum number of attempts to make for a connection: for the initial connection request, and
107
+ * again for each reconnect of an established connection. When the initial request reaches the limit
108
+ * the {@link IEventBus} returns an error to the caller of {@link IEventBus#connect}; when a reconnect
109
+ * does, the connection ends for good and {@link IEventBus#connectionEnded} carries the failure.
103
110
  * Set to 0, undefined, or null to try forever
104
111
  */
105
112
  maxConnectionAttempts?: number | null;
@@ -124,7 +131,7 @@ interface Identifiable<T> {
124
131
  *
125
132
  * This is the base shape every participant shares, regardless of scope, and is what RPC-only
126
133
  * consumers work with directly. The Kinotic OS contract layers scope-typed participants on top
127
- * of it — see the participant types in {@code @kinotic-ai/os-api}.
134
+ * of it — see the participant types in {@code @kinotic-ai/management-api}.
128
135
  *
129
136
  * Mirrors the server {@code org.kinotic.core.api.security.Participant}.
130
137
  *
@@ -146,7 +153,7 @@ interface IParticipant extends Identifiable<string> {
146
153
  }
147
154
  /**
148
155
  * A logged-in participant on the RPC layer. Alias of {@link IParticipant}; the Kinotic OS contract
149
- * ({@code @kinotic-ai/os-api}) narrows this to scope-typed participants.
156
+ * ({@code @kinotic-ai/management-api}) narrows this to scope-typed participants.
150
157
  *
151
158
  * Created by Navid Mitchell on 6/2/20
152
159
  */
@@ -159,7 +166,7 @@ declare class ConnectedInfo {
159
166
  participant: Participant;
160
167
  }
161
168
  /**
162
- * Part of the low level portion of kinoitc representing data to be processed
169
+ * Part of the low level portion of kinotic representing data to be processed
163
170
  *
164
171
  * This is similar to a Stomp Frame but with more required information and no control plane semantics.
165
172
  *
@@ -215,17 +222,35 @@ interface IEvent {
215
222
  setHeader(key: string, value: string): void;
216
223
  }
217
224
  /**
218
- * Part of the low level portion of kinoitc representing a connection to a kinoitc server
225
+ * Part of the low level portion of kinotic representing a connection to a kinotic server
219
226
  * This is similar to a Stomp Client but with more required information and no control plane semantics.
220
227
  *
221
228
  * Created by Navid Mitchell on 2019-01-04.
222
229
  */
223
230
  interface IEventBus {
224
231
  /**
225
- * Any errors emitted by this observable will be fatal and the connection will be closed.
226
- * You will need to resolve the problem and reconnect.
232
+ * Emits when the connection ends: an established connection drops before any reconnect, a failure
233
+ * closes it, or {@link disconnect} is called. It carries the failure that ended the connection, or
234
+ * null when nothing failed. The server releases everything it held for the connection at that moment:
235
+ * every request made on it is failed to its caller, and every invocation it was serving is failed to
236
+ * its requester. An end the client reconnects from leaves {@link IEventBus#isConnectionActive} true;
237
+ * one that needs a fresh {@link IEventBus#connect} leaves it false.
238
+ */
239
+ connectionEnded: Observable<Error | null>;
240
+ /**
241
+ * Emits each time a connection is established: the first {@link connect}, and every reconnect the
242
+ * client makes after one ends. It carries the {@link ConnectedInfo} the server issued for that
243
+ * connection, which names the session the requests made on it belong to.
244
+ */
245
+ connectionEstablished: Observable<ConnectedInfo>;
246
+ /**
247
+ * Emits each time an attempt to connect fails before the server accepts the connection and the client
248
+ * will try again: the server could not be reached, it closed the socket before answering, or it had not
249
+ * answered within 10 seconds of the socket being opened. This
250
+ * covers the attempts of a pending {@link connect} as well as the reconnects after a connection ends.
251
+ * An attempt that ends the connection for good is reported by {@link connectionEnded} instead.
227
252
  */
228
- fatalErrors: Observable<Error>;
253
+ connectionAttemptFailed: Observable<void>;
229
254
  /**
230
255
  * The {@link ServerInfo} used when connecting, if connected or null
231
256
  */
@@ -249,14 +274,15 @@ interface IEventBus {
249
274
  disconnect(force?: boolean): Promise<void>;
250
275
  /**
251
276
  * Determines if the connection is connected.
252
- * This means that there is an open connection to the Kinoitc server
277
+ * This means that there is an open connection to the Kinotic server
253
278
  * @return true if the connection is active false if not
254
279
  */
255
280
  isConnected(): boolean;
256
281
  /**
257
282
  * Determines if the connection is active.
258
283
  * This means {@link IEventBus#connect()} was called and was successful. The underlying connection may not be established yet.
259
- * If this is true and {@link IEventBus#isConnected} is false messages sent will be queued
284
+ * Subscriptions made while active are established once the connection comes up; sends require
285
+ * {@link IEventBus#isConnected}
260
286
  * @return true if the connection is active false if not
261
287
  */
262
288
  isConnectionActive(): boolean;
@@ -288,8 +314,11 @@ interface IEventBus {
288
314
  */
289
315
  requestStream(event: IEvent, sendControlEvents: boolean): Observable<IEvent>;
290
316
  /**
291
- * Send a single {@link IEvent} to the connected server
317
+ * Send a single {@link IEvent} to the connected server. Events are never held for a later
318
+ * connection, so the caller decides what an event it could not send means — see
319
+ * {@link isConnected}.
292
320
  * @param event to send
321
+ * @throws if the connection is not established
293
322
  */
294
323
  send(event: IEvent): void;
295
324
  }
@@ -302,6 +331,12 @@ declare enum EventConstants {
302
331
  CONTENT_LENGTH_HEADER = "content-length",
303
332
  REPLY_TO_HEADER = "reply-to",
304
333
  /**
334
+ * The participant that sent the event, as JSON. The gateway writes it on every event it delivers to a
335
+ * client, from the participant authenticated on the connection the event came from, and drops any a
336
+ * client supplies; an event that originated inside the platform with no participant bound carries none.
337
+ */
338
+ SENDER_HEADER = "sender",
339
+ /**
305
340
  * Header provided by the server on connection to provide the {@link ConnectedInfo} as a JSON string
306
341
  */
307
342
  CONNECTED_INFO_HEADER = "connected-info",
@@ -363,16 +398,25 @@ declare enum EventConstants {
363
398
  TRACESTATE_HEADER = "tracestate"
364
399
  }
365
400
  /**
366
- * Interface for the service context, extendable by users for type-safe context data.
401
+ * The request context a {@link Context} method receives as its final parameter: the calling participant,
402
+ * plus whatever the registered {@link ContextInterceptor} adds. Extend it for type-safe context data.
367
403
  *
368
404
  * @author Navid Mitchell 🤝Grok
369
405
  * @since 3/25/2025
370
406
  */
371
407
  interface ServiceContext {
408
+ /**
409
+ * The participant that invoked the service method, as authenticated by the gateway on the calling
410
+ * connection. Absent when the invocation originated inside the platform with no participant bound,
411
+ * such as a scheduled job.
412
+ */
413
+ participant?: Participant;
372
414
  [key: string]: any;
373
415
  }
374
416
  /**
375
417
  * Interface for interceptors that create or modify the ServiceContext before service method invocation.
418
+ * The context handed in already carries the calling participant; the context returned is the one the
419
+ * method receives.
376
420
  *
377
421
  * @author Navid Mitchell 🤝Grok
378
422
  * @since 3/25/2025
@@ -380,10 +424,62 @@ interface ServiceContext {
380
424
  interface ContextInterceptor<T extends ServiceContext> {
381
425
  intercept(event: IEvent, context: T): Promise<T> | T;
382
426
  }
427
+ import { Observable as Observable2 } from "rxjs";
428
+ /**
429
+ * How a session ended when its client did not end it.
430
+ */
431
+ declare enum SessionEndType {
432
+ /** The gateway holds no login for the page any more: the session expired, the user signed out elsewhere, or the user was disabled. */
433
+ SIGNED_OUT = "SIGNED_OUT",
434
+ /** The connection ended for good while the gateway still holds the page's login, or while it gives no answer. */
435
+ CONNECTION_LOST = "CONNECTION_LOST"
436
+ }
437
+ /**
438
+ * The end of a session that its client did not ask for.
439
+ */
440
+ interface SessionEnd {
441
+ /** Whether the page was signed out or only its connection was lost. */
442
+ type: SessionEndType;
443
+ /** The failure that ended the connection; its {@code cause} chain leads to the server's own reason. */
444
+ cause: Error;
445
+ }
446
+ /**
447
+ * The browser session of a page: the login a gateway's REST sign-in established for it, held in the
448
+ * session cookie, and the connection opened on that login. Calls to {@link resume} and {@link logout}
449
+ * run one at a time, in the order they were made.
450
+ */
451
+ interface ISession {
452
+ /**
453
+ * The {@link ConnectedInfo} of the session's connection, following each reconnect, or null while
454
+ * the session holds no connection.
455
+ */
456
+ readonly connectedInfo: ConnectedInfo | null;
457
+ /**
458
+ * Opens the connection on the page's session cookie; rejects when the gateway holds no login for it.
459
+ * A connection the client already holds is closed first, and a rejected call leaves none open. A
460
+ * gateway that gives no answer is retried, so the call stays pending until it answers unless
461
+ * {@link ConnectOptions#maxConnectionAttempts} bounds it.
462
+ * @param options the server to reach and the connection's settings, resolved as {@link IKinotic#connect} resolves them
463
+ * @return the {@link ConnectedInfo} of the connection
464
+ */
465
+ resume(options?: ConnectOptions): Promise<ConnectedInfo>;
466
+ /**
467
+ * Ends the page's login on the gateway the client is connected to, or last resumed on, then closes
468
+ * the connection. Resolves once both were tried, whether or not either succeeded.
469
+ */
470
+ logout(): Promise<void>;
471
+ /**
472
+ * Emits when the session ends without this client asking, classified once: a failure ended the
473
+ * session's connection for good, and the client has made no {@link resume} or {@link logout}
474
+ * since. The gateway is asked which end it was: it ended the login, or the connection was lost
475
+ * while the login lives.
476
+ */
477
+ readonly ended: Observable2<SessionEnd>;
478
+ }
383
479
  /**
384
- * `CRI` is a Kinoitc Resource Identifier used by Kinoitc to route requests appropriately.
480
+ * `CRI` is a Kinotic Resource Identifier used by Kinotic to route requests appropriately.
385
481
  *
386
- * The `CRI` is a URI where the parts are named differently for clarity as to their purpose within Kinoitc.
482
+ * The `CRI` is a URI where the parts are named differently for clarity as to their purpose within Kinotic.
387
483
  *
388
484
  * Will be in a format as follows where anything surrounded with `[]` is optional:
389
485
  *
@@ -421,7 +517,7 @@ interface CRI {
421
517
  * The zone this `CRI` is addressed in, or `null` if un-zoned.
422
518
  *
423
519
  * The zone is the isolation boundary routing is validated against, such as
424
- * `app.acme-org.orders-app` or `os-api`.
520
+ * `app.acme-org.orders-app` or `management-api`.
425
521
  *
426
522
  * For the following CRI, `zone` would be the portion specified by `zone`:
427
523
  *
@@ -540,8 +636,14 @@ declare class ServiceIdentifier {
540
636
  * @return the cri for this {@link ServiceIdentifier}
541
637
  */
542
638
  cri(): CRI;
639
+ /**
640
+ * The {@link CRI} of this service's shared, unscoped address. Every instance of a scoped
641
+ * service may listen here for the methods any instance can answer.
642
+ * @return the cri without the scope part
643
+ */
644
+ unscopedCri(): CRI;
543
645
  }
544
- import { Observable as Observable2 } from "rxjs";
646
+ import { Observable as Observable3 } from "rxjs";
545
647
  /**
546
648
  * Provides an interface to allow the {@link IServiceProxy} creator the ability to have fine grain control of the outgoing {@link IEvent}
547
649
  */
@@ -575,7 +677,7 @@ interface IServiceProxy {
575
677
  * @param eventFactory IEventFactory or undefined or null, if not undefined or null this is the {@link IEventFactory} to use when creating {@link IEvent}'s to send
576
678
  * @return a {@link Observable} that will resolve to the result from the invocation
577
679
  */
578
- invokeStream(methodIdentifier: string, args?: any[] | null | undefined, scope?: string | null | undefined, eventFactory?: IEventFactory | null | undefined): Observable2<any>;
680
+ invokeStream(methodIdentifier: string, args?: any[] | null | undefined, scope?: string | null | undefined, eventFactory?: IEventFactory | null | undefined): Observable3<any>;
579
681
  }
580
682
  /**
581
683
  * Provides the functionality to register services as well as create proxies for those services
@@ -612,6 +714,7 @@ interface IServiceRegistry {
612
714
  */
613
715
  registerContextInterceptor<T extends ServiceContext>(interceptor: ContextInterceptor<T> | null): void;
614
716
  }
717
+ import { ServiceDefinition } from "@kinotic-ai/idl";
615
718
  /**
616
719
  * An implementation of a {@link IEventFactory} which uses JSON content
617
720
  */
@@ -625,11 +728,20 @@ declare class TextEventFactory implements IEventFactory {
625
728
  create(cri: string, args: any[] | null | undefined): IEvent;
626
729
  }
627
730
  /**
731
+ * Declares the definitions of the project's published services, as `kinotic sync` generates them into the
732
+ * project's ServiceDefinitions module, so every registry registers each service in the platform's service
733
+ * directory with its definition when the service comes online. A definition declared again for a qualified
734
+ * name replaces the one held.
735
+ * @param definitions the generated definitions
736
+ */
737
+ declare function declareServiceDefinitions(definitions: ServiceDefinition[]): void;
738
+ /**
628
739
  * The default implementation of {@link IServiceRegistry}
629
740
  */
630
741
  declare class ServiceRegistry implements IServiceRegistry {
631
742
  private _eventBus;
632
743
  private supervisors;
744
+ private entries;
633
745
  private contextInterceptor;
634
746
  private debugLogger;
635
747
  constructor(eventBus: IEventBus);
@@ -638,6 +750,14 @@ declare class ServiceRegistry implements IServiceRegistry {
638
750
  serviceProxy(serviceIdentifier: string): IServiceProxy;
639
751
  register(serviceIdentifier: ServiceIdentifier, service: any): void;
640
752
  unRegister(serviceIdentifier: ServiceIdentifier): void;
753
+ /**
754
+ * Registers every application service registered so far in the platform's service directory, with the
755
+ * definition the project declared for it, so the directory lists the service and the platform checks
756
+ * requests to it; a service the platform refuses fails the registration. A service registered later is
757
+ * registered in the directory as it registers here.
758
+ */
759
+ registerEntries(): Promise<void>;
760
+ private registerEntry;
641
761
  registerContextInterceptor<T extends ServiceContext>(interceptor: ContextInterceptor<T> | null): void;
642
762
  }
643
763
  /**
@@ -650,8 +770,13 @@ interface IKinotic {
650
770
  serviceRegistry: IServiceRegistry;
651
771
  eventBus: IEventBus;
652
772
  /**
773
+ * The browser session of the page this client runs in, for a client that signs in through a gateway's
774
+ * REST login rather than with credentials of its own.
775
+ */
776
+ readonly session: ISession;
777
+ /**
653
778
  * The zone prefix every service published by this client registers under, such as
654
- * `app.<organizationId>.<applicationId>` for an application or `system` for a platform
779
+ * `app.<organizationId>.<applicationId>` for an application or `system` for a system
655
780
  * workload. Must be set from static configuration before service classes are instantiated.
656
781
  * When null, services register at un-zoned legacy addresses.
657
782
  */
@@ -699,14 +824,17 @@ declare class KinoticSingleton implements IKinotic {
699
824
  * The {@link ServiceRegistry} that is used to manage the services that are available
700
825
  */
701
826
  readonly serviceRegistry: ServiceRegistry;
827
+ private readonly _session;
702
828
  zonePrefix: string | null;
703
829
  defaultZone: string | null;
704
830
  constructor();
831
+ get session(): ISession;
705
832
  get eventBus(): IEventBus;
706
833
  set eventBus(eventBus: IEventBus);
707
834
  /**
708
- * Connects to a Kinotic server. Every option is optional: absent server fields and
709
- * credentials resolve from the environment — see {@link ConnectOptions}.
835
+ * Connects to a Kinotic server and registers the application services registered so far in the platform's
836
+ * service directory. Every option is optional: absent server fields and credentials resolve from the
837
+ * environment — see {@link ConnectOptions}.
710
838
  * @param options overrides for the resolved connection, or nothing to resolve everything
711
839
  * @return Promise containing the result of the initial connection attempt
712
840
  */
@@ -740,6 +868,19 @@ declare const Kinotic: KinoticSingleton;
740
868
  */
741
869
  declare function Scope(value: Function, _context: ClassGetterDecoratorContext | ClassMethodDecoratorContext): void;
742
870
  /**
871
+ * Marks a method of a scoped published service that any instance may answer, because its
872
+ * result does not depend on which instance executes it - typically a read of shared state
873
+ * rather than of the instance's own.
874
+ *
875
+ * A scoped service normally listens only at its scoped address, so every invocation must name
876
+ * an instance. When at least one method carries ScopeOptional, each instance also listens on
877
+ * the service's shared unscoped address, where only the annotated methods may be invoked: an
878
+ * unscoped invocation of any other method is rejected, since it would execute on whichever
879
+ * instance happened to receive it.
880
+ */
881
+ declare function ScopeOptional(value: Function, _context: ClassMethodDecoratorContext): void;
882
+ declare function scopeOptionalMethodNames(instance: object): Set<string>;
883
+ /**
743
884
  * Sets the semantic version a service registers under.
744
885
  * @param version the version in X.Y.Z[-optional] format
745
886
  */
@@ -781,6 +922,34 @@ declare function receivesContext(serviceInstance: object, methodName: string): b
781
922
  * so it appears in directory listings
782
923
  */
783
924
  declare function Publish(namespace?: string | null, name?: string, advertise?: boolean): <T extends new (...args: any[]) => object>(value: T, _context: ClassDecoratorContext<any>) => T;
925
+ import { ServiceDefinition as ServiceDefinition2 } from "@kinotic-ai/idl";
926
+ /**
927
+ * A service of an application as its runtime registers it in the platform's service directory: the application
928
+ * it belongs to, where it is addressed, whether it is advertised, and its definition. The platform owns
929
+ * everything else about the directory's entry, such as the service's liveness.
930
+ */
931
+ interface ServiceDirectoryEntry {
932
+ /**
933
+ * The application the service belongs to, which its zone names.
934
+ */
935
+ applicationId: string;
936
+ /**
937
+ * The zone the service is addressed in, the application's or a label under it.
938
+ */
939
+ zone: string;
940
+ /**
941
+ * The version the service registers under, or null for none.
942
+ */
943
+ version: string | null;
944
+ /**
945
+ * True when the service advertised itself with `@Publish(advertise = true)` and appears in directory listings.
946
+ */
947
+ advertised: boolean;
948
+ /**
949
+ * The service's definition: its functions, with the parameters a request carries and what each returns.
950
+ */
951
+ serviceDefinition: ServiceDefinition2;
952
+ }
784
953
  /**
785
954
  * Validates that the given zone satisfies the zone grammar
786
955
  * @param zone the zone to validate
@@ -1093,6 +1262,16 @@ interface ICrudServiceProxy<T extends Identifiable<string>> extends IEditableDat
1093
1262
  */
1094
1263
  deleteById(id: string): Promise<void>;
1095
1264
  /**
1265
+ * Deletes the entity with the given id and waits for the deletion to be visible in search
1266
+ * results before returning.
1267
+ * Use this when you need read-your-write consistency immediately after deletion.
1268
+ *
1269
+ * @param id must not be {@literal null}.
1270
+ * @return a {@link Promise} signaling when the deletion is visible to search.
1271
+ * @throws IllegalArgumentException in case the given {@literal identity} is {@literal null}.
1272
+ */
1273
+ deleteByIdSync(id: string): Promise<void>;
1274
+ /**
1096
1275
  * Returns a {@link Page} of entities meeting the paging restriction provided in the {@code Pageable} object.
1097
1276
  *
1098
1277
  * @param pageable the page settings to be used
@@ -1123,6 +1302,7 @@ declare class CrudServiceProxy<T extends Identifiable<string>> implements ICrudS
1123
1302
  create(entity: T): Promise<T>;
1124
1303
  createSync(entity: T): Promise<T>;
1125
1304
  deleteById(id: string): Promise<void>;
1305
+ deleteByIdSync(id: string): Promise<void>;
1126
1306
  findAll(pageable: Pageable): Promise<IterablePage<T>>;
1127
1307
  findAllSinglePage(pageable: Pageable): Promise<Page<T>>;
1128
1308
  findById(id: string): Promise<T>;
@@ -1190,7 +1370,7 @@ declare class DefaultCRI implements CRI {
1190
1370
  private static parseRaw;
1191
1371
  private static buildRaw;
1192
1372
  }
1193
- import { Observable as Observable3 } from "rxjs";
1373
+ import { Observable as Observable4 } from "rxjs";
1194
1374
  import { Optional as Optional2 } from "typescript-optional";
1195
1375
  /**
1196
1376
  * Default IEvent implementation
@@ -1212,17 +1392,21 @@ declare class Event implements IEvent {
1212
1392
  */
1213
1393
  declare class EventBus implements IEventBus {
1214
1394
  serverInfo: ServerInfo | null;
1395
+ private readonly log;
1215
1396
  private stompConnectionManager;
1216
1397
  private connectionLifecycle;
1217
- private replyToCri;
1398
+ private disconnectRequests;
1218
1399
  private requestRepliesObservable;
1219
1400
  private requestRepliesSubject;
1220
1401
  private requestRepliesSubscription;
1221
1402
  private readonly activeCorrelationIds;
1222
1403
  private readonly recentlyReaped;
1404
+ private readonly connectionEndedSubject;
1223
1405
  private static readonly REAP_DEBOUNCE_MS;
1224
1406
  constructor();
1225
- get fatalErrors(): Observable3<Error>;
1407
+ get connectionEnded(): Observable4<Error | null>;
1408
+ get connectionEstablished(): Observable4<ConnectedInfo>;
1409
+ get connectionAttemptFailed(): Observable4<void>;
1226
1410
  isConnectionActive(): boolean;
1227
1411
  isConnected(): boolean;
1228
1412
  connect(options: ConnectOptions): Promise<ConnectedInfo>;
@@ -1231,10 +1415,9 @@ declare class EventBus implements IEventBus {
1231
1415
  private serializeLifecycle;
1232
1416
  send(event: IEvent): void;
1233
1417
  request(event: IEvent): Promise<IEvent>;
1234
- requestStream(event: IEvent, sendControlEvents?: boolean): Observable3<IEvent>;
1418
+ requestStream(event: IEvent, sendControlEvents?: boolean): Observable4<IEvent>;
1235
1419
  listen(_serverInfo: ServerInfo): Promise<void>;
1236
- observe(cri: string): Observable3<IEvent>;
1237
- private cleanup;
1420
+ observe(cri: string): Observable4<IEvent>;
1238
1421
  /**
1239
1422
  * Cancels a server stream whose reply arrived for a correlationId we no longer track. The server can't
1240
1423
  * detect this itself since all requests share one reply destination, so the cancel is sent to the
@@ -1242,8 +1425,14 @@ declare class EventBus implements IEventBus {
1242
1425
  */
1243
1426
  private cancelIfUnexpected;
1244
1427
  /**
1428
+ * Sends the control event that stops the server stream identified by the correlationId.
1429
+ * @param cri the service the stream originates from
1430
+ * @param correlationId the correlationId of the stream to cancel
1431
+ */
1432
+ private sendCancel;
1433
+ /**
1245
1434
  * Tears down the shared request-replies stream so the next request rebuilds it against the
1246
- * current {@link replyToCri}. Any in-flight requests are failed with the given reason since
1435
+ * connection's reply destination. Any in-flight requests are failed with the given reason since
1247
1436
  * their replies can no longer be delivered.
1248
1437
  */
1249
1438
  private resetRequestReplies;
@@ -1260,6 +1449,38 @@ declare class EventBus implements IEventBus {
1260
1449
  private _observe;
1261
1450
  }
1262
1451
  /**
1452
+ * The error a service call fails with when the server answered it with an error reply. The reply body
1453
+ * describes the exception the server caught, so a caller can branch on which exception it was rather than
1454
+ * on a message written for people: a call that failed because the node serving it left the cluster carries
1455
+ * `RpcServiceUnavailableException`, one rejected because nothing served its address
1456
+ * `RpcMissingServiceException`.
1457
+ */
1458
+ declare class RpcError extends Error {
1459
+ /**
1460
+ * The simple name of the exception the server caught, such as `RpcServiceUnavailableException`.
1461
+ */
1462
+ readonly exceptionName: string;
1463
+ /**
1464
+ * The fully qualified class name of the exception the server caught.
1465
+ */
1466
+ readonly exceptionClass: string;
1467
+ constructor(message: string, exceptionName: string, exceptionClass: string);
1468
+ /**
1469
+ * Builds the error an error reply carries. The body is the server's description of the exception when
1470
+ * it is JSON; otherwise the error header alone names the failure.
1471
+ * @param reply the error reply, which carries the error header
1472
+ */
1473
+ static fromEvent(reply: IEvent): RpcError;
1474
+ }
1475
+ /**
1476
+ * Thrown when the calling participant is not permitted to do what it asked. A service that throws it
1477
+ * fails the invocation with an error reply named {@code AuthorizationException}, the name a Java
1478
+ * service's refusal carries, so a caller reads both the same way.
1479
+ */
1480
+ declare class AuthorizationException extends Error {
1481
+ constructor(message?: string);
1482
+ }
1483
+ /**
1263
1484
  * Kinotic client credentials: a clientId/clientSecret pair presented as upgrade headers —
1264
1485
  * a user's email and password, or a machine identity's id and provisioned secret. Scope is
1265
1486
  * structural, determined by which ids are given: neither → SYSTEM, organizationId only →
@@ -1322,9 +1543,9 @@ declare class ParticipantConstants {
1322
1543
  static readonly PARTICIPANT_TYPE_USER: string;
1323
1544
  /** A client (CLI, MCP host) acting on behalf of a user that authorized it. */
1324
1545
  static readonly PARTICIPANT_TYPE_DELEGATE: string;
1325
- /** A non-human caller with its own credential — a platform daemon or an external API client. */
1546
+ /** A non-human caller with its own credential — a system daemon or an external API client. */
1326
1547
  static readonly PARTICIPANT_TYPE_MACHINE: string;
1327
- /** The clientId TestSecurityService (clienttest profile) maps to the ANONYMOUS role in core package tests. */
1548
+ /** The clientId the test server's TestSecurityService maps to the ANONYMOUS role in core package tests. */
1328
1549
  static readonly CLI_PARTICIPANT_ID: string;
1329
1550
  }
1330
- export { validateZone, validateLabel, receivesContext, isAdvertised, createCRI, buildServerUrl, buildBrokerUrl, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, SessionCredentialsResolver, ServiceRegistry, ServiceContext, ServerInfo, Scope, ResolvedCredentials, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, FunctionalIterablePage, EventConstants, EventBus, Event, EnvCredentialsResolver, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, CredentialsResolver, ContextInterceptor, Context, ConnectedInfo, ConnectOptions, ChainedCredentialsResolver, CRI, BearerCredentialsResolver, BasicCredentialsResolver, AbstractIterablePage };
1551
+ export { AbstractIterablePage, AuthorizationException, BasicCredentialsResolver, BearerCredentialsResolver, CRI, ChainedCredentialsResolver, ConnectOptions, ConnectedInfo, Context, ContextInterceptor, CredentialsResolver, CrudServiceProxy, CrudServiceProxyFactory, CursorPageable, DataSourceUtils, DefaultCRI, Direction, EnvCredentialsResolver, Event, EventBus, EventConstants, FunctionalIterablePage, ICrudServiceProxy, ICrudServiceProxyFactory, IDataSource, IEditableDataSource, IEvent, IEventBus, IEventFactory, IKinotic, IParticipant, IServiceProxy, IServiceRegistry, ISession, IWebSocket, Identifiable, IterablePage, JsonEventFactory, Kinotic, KinoticPlugin, KinoticSingleton, NullHandling, OffsetPageable, Order, Page, Pageable, Participant, ParticipantConstants, Publish, ResolvedCredentials, RpcError, Scope, ScopeOptional, ServerInfo, ServiceContext, ServiceDirectoryEntry, ServiceIdentifier, ServiceRegistry, SessionCredentialsResolver, SessionEnd, SessionEndType, SessionKeepAliveMode, Sort, TextEventFactory, Version, WebSocketFactory, Zone, buildBrokerUrl, buildServerUrl, createCRI, declareServiceDefinitions, isAdvertised, receivesContext, scopeOptionalMethodNames, validateLabel, validateZone };