@x1a0f3n9/dsh-typert-protocol 0.1.2-alpha.6
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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +149 -0
- package/README.zh.md +149 -0
- package/lib/index.js +184 -0
- package/lib/types/index.d.ts +97 -0
- package/lib/types/index.js +162 -0
- package/lib/types/remote-error.d.ts +31 -0
- package/lib/types/remote-error.js +44 -0
- package/lib/types/types.d.ts +481 -0
- package/lib/types/types.js +7 -0
- package/package.json +40 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiler-independent Typert protocol shared by business packages, generated
|
|
3
|
+
* Remote artifacts, the Host Gateway, and Client API implementations.
|
|
4
|
+
* @module @x1a0f3n9/dsh-typert-protocol/types
|
|
5
|
+
*/
|
|
6
|
+
import type { Context, Events } from '@deepseek-ai/cordis';
|
|
7
|
+
declare const LOOKUP_HOST: unique symbol;
|
|
8
|
+
declare const LOOKUP_WIRE: unique symbol;
|
|
9
|
+
declare const CONTEXT_WIRE: unique symbol;
|
|
10
|
+
/** Type-level association between a Host object and its wire identity. */
|
|
11
|
+
export interface TypertLookup<Host, Wire> {
|
|
12
|
+
readonly [LOOKUP_HOST]: Host;
|
|
13
|
+
readonly [LOOKUP_WIRE]: Wire;
|
|
14
|
+
}
|
|
15
|
+
/** Extract the Host object associated with one lookup declaration. */
|
|
16
|
+
export type TypertLookupHost<Lookup> = Lookup extends TypertLookup<infer Host, infer _Wire> ? Host : never;
|
|
17
|
+
/** Extract the wire identity associated with one lookup declaration. */
|
|
18
|
+
export type TypertLookupWire<Lookup> = Lookup extends TypertLookup<infer _Host, infer Wire> ? Wire : never;
|
|
19
|
+
/** Type-level association between a scoped Context kind and its wire identity. */
|
|
20
|
+
export interface TypertContext<Wire> {
|
|
21
|
+
readonly [CONTEXT_WIRE]: Wire;
|
|
22
|
+
}
|
|
23
|
+
/** Extract the wire identity associated with one scoped Context declaration. */
|
|
24
|
+
export type TypertContextWire<ContextType> = ContextType extends TypertContext<infer Wire> ? Wire : never;
|
|
25
|
+
/** Merge-extensible Host object lookup declarations. */
|
|
26
|
+
export interface TypertLookupMap {
|
|
27
|
+
}
|
|
28
|
+
/** Merge-extensible scoped Context declarations. */
|
|
29
|
+
export interface TypertContextMap {
|
|
30
|
+
}
|
|
31
|
+
/** Merge-extensible direct Remote method signatures generated for consumers. */
|
|
32
|
+
export interface TypertRemoteMap {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Merge-extensible Remote failure vocabulary: this package declares the
|
|
36
|
+
* universal carrier codes once; the Gateway merges its infrastructure codes
|
|
37
|
+
* and every owner merges its domain codes next to the throwing code.
|
|
38
|
+
*/
|
|
39
|
+
export interface RemoteErrorDetailsMap {
|
|
40
|
+
/** Owner-side business validation refused the request; `issues` carries codec output when one produced it. */
|
|
41
|
+
'gateway/bad-request': {
|
|
42
|
+
readonly issues?: readonly object[];
|
|
43
|
+
};
|
|
44
|
+
/** The call was cancelled by the carrier signal or the backend. */
|
|
45
|
+
'gateway/cancelled': {};
|
|
46
|
+
/** Carrier, dispatch, or unclassified Host failure. */
|
|
47
|
+
'gateway/internal': {};
|
|
48
|
+
}
|
|
49
|
+
/** Every declared Remote failure code. */
|
|
50
|
+
export type RemoteErrorCode = keyof RemoteErrorDetailsMap;
|
|
51
|
+
/**
|
|
52
|
+
* One Remote call's failure: the code-discriminated union of RemoteError
|
|
53
|
+
* instances, so a `code` branch narrows `details` with no cast.
|
|
54
|
+
*/
|
|
55
|
+
export type RemoteFailure = {
|
|
56
|
+
[Code in RemoteErrorCode]: import('./remote-error.ts').RemoteError<Code>;
|
|
57
|
+
}[RemoteErrorCode];
|
|
58
|
+
/**
|
|
59
|
+
* What every generated Remote method resolves to. The Remote face itself folds
|
|
60
|
+
* carrier failures into the error branch, so no consumer wraps a call to
|
|
61
|
+
* recover one; only assembly faults (arity, an unmounted method, a missing
|
|
62
|
+
* Context adapter) still reject.
|
|
63
|
+
* @template T - the Host method's business result.
|
|
64
|
+
*/
|
|
65
|
+
export type RemoteResult<T> = {
|
|
66
|
+
readonly ok: true;
|
|
67
|
+
readonly value: T;
|
|
68
|
+
} | {
|
|
69
|
+
readonly ok: false;
|
|
70
|
+
readonly error: RemoteFailure;
|
|
71
|
+
};
|
|
72
|
+
/** Merge-extensible scoped Remote method signatures generated for consumers. */
|
|
73
|
+
export interface TypertRemoteScopeMap {
|
|
74
|
+
}
|
|
75
|
+
type TypertEventParameters<Event extends keyof Events> = Events[Event] extends (...args: infer Args) => unknown ? Args : never;
|
|
76
|
+
type TypertEventResult<Event extends keyof Events> = Events[Event] extends (...args: never[]) => infer Result ? Result : never;
|
|
77
|
+
type TypertProjectedContextKey = Extract<keyof TypertLookupMap, keyof TypertContextMap>;
|
|
78
|
+
type TypertProjectedContextSubject = {
|
|
79
|
+
[Key in TypertProjectedContextKey]: TypertLookupHost<TypertLookupMap[Key]>;
|
|
80
|
+
}[TypertProjectedContextKey];
|
|
81
|
+
type TypertAgentScopedRequest<Request> = Request extends object ? 'agent' extends keyof Request ? Exclude<Request['agent'], undefined> extends TypertProjectedContextSubject ? Request : never : never : never;
|
|
82
|
+
type TypertWaterfallEvent<Event extends keyof Events> = unknown extends ThisParameterType<Events[Event]> ? never : TypertEventParameters<Event> extends [infer Request, infer Next] ? Next extends () => TypertEventResult<Event> ? TypertEventResult<Event> extends Promise<unknown> ? TypertAgentScopedRequest<Request> extends never ? never : Event : never : never : never;
|
|
83
|
+
type TypertForwardingMode<Event extends keyof Events> = unknown extends ThisParameterType<Events[Event]> ? TypertEventResult<Event> extends void ? 'emit' : never : TypertWaterfallEvent<Event> extends never ? never : 'waterfall';
|
|
84
|
+
/**
|
|
85
|
+
* Cordis event names the Remote Event carrier can preserve without a second
|
|
86
|
+
* signature declaration: unscoped `void` notifications and scoped async
|
|
87
|
+
* waterfalls whose final parameter is their same-result `next()` callback.
|
|
88
|
+
*/
|
|
89
|
+
export type TypertForwardableEvent = {
|
|
90
|
+
[Event in keyof Events]: TypertForwardingMode<Event> extends never ? never : Event;
|
|
91
|
+
}[keyof Events];
|
|
92
|
+
/** Event and dispatch mode accepted by the Remote Event source. */
|
|
93
|
+
export type TypertForwardableEventEntry = {
|
|
94
|
+
[Event in keyof Events]: TypertForwardingMode<Event> extends infer Mode ? Mode extends 'emit' | 'waterfall' ? {
|
|
95
|
+
readonly event: Event;
|
|
96
|
+
readonly mode: Mode;
|
|
97
|
+
} : never : never;
|
|
98
|
+
}[keyof Events];
|
|
99
|
+
/** Merge-extensible forwarding selection declared once by the Host assembly. */
|
|
100
|
+
export interface TypertRemoteEventSelection {
|
|
101
|
+
}
|
|
102
|
+
/** Legal `$on` keys selected from the carrier-compatible Cordis event declarations. */
|
|
103
|
+
export type TypertRemoteEvent = Extract<TypertForwardableEvent, keyof TypertRemoteEventSelection>;
|
|
104
|
+
type TypertClientAgent<Value> = Exclude<Value, undefined> extends TypertProjectedContextSubject ? Context | Extract<Value, undefined> : Value;
|
|
105
|
+
type TypertClientEventRequest<Request> = Request extends object ? {
|
|
106
|
+
[Key in keyof Request]: Key extends 'agent' ? TypertClientAgent<Request[Key]> : Request[Key];
|
|
107
|
+
} : never;
|
|
108
|
+
type TypertScopedClientEventListener<Event extends TypertRemoteEvent> = Events[Event] extends (request: infer Request, next: infer Next) => infer Result ? (this: Context, request: TypertClientEventRequest<Request>, next: Next) => Result : never;
|
|
109
|
+
/**
|
|
110
|
+
* Listener derived from one selected Cordis event declaration. Scoped Host
|
|
111
|
+
* subjects become the resolved Client `Context`; one-way notifications retain
|
|
112
|
+
* their declaration unchanged.
|
|
113
|
+
* @template Event - selected Remote Event name.
|
|
114
|
+
*/
|
|
115
|
+
export type TypertClientEventListener<Event extends TypertRemoteEvent> = unknown extends ThisParameterType<Events[Event]> ? Events[Event] : TypertScopedClientEventListener<Event>;
|
|
116
|
+
/**
|
|
117
|
+
* Resolve one direct Remote namespace from the generated flat endpoint map.
|
|
118
|
+
* @template Namespace - wire namespace before the endpoint slash.
|
|
119
|
+
*/
|
|
120
|
+
export type TypertRemoteNamespace<Namespace extends string> = {
|
|
121
|
+
[Endpoint in keyof TypertRemoteMap as Endpoint extends `${Namespace}/${infer Method}` ? Method : never]: TypertRemoteMap[Endpoint];
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Resolve one scoped Remote namespace across every generated Context kind.
|
|
125
|
+
* The calling Cordis Context supplies the concrete identity at runtime.
|
|
126
|
+
* @template Namespace - wire namespace between the Context prefix and method.
|
|
127
|
+
*/
|
|
128
|
+
export type TypertRemoteScopeNamespace<Namespace extends string, ContextKey extends string = string> = {
|
|
129
|
+
[Endpoint in keyof TypertRemoteScopeMap as Endpoint extends `${ContextKey}:${Namespace}/${infer Method}` ? Method : never]: TypertRemoteScopeMap[Endpoint];
|
|
130
|
+
};
|
|
131
|
+
type TypertRemoteScopeNamespaceKey<ContextKey extends string, Endpoint = keyof TypertRemoteScopeMap> = Endpoint extends `${ContextKey}:${infer Namespace}/${string}` ? Namespace : never;
|
|
132
|
+
/** Generated scoped Remote namespaces available to one Context kind. */
|
|
133
|
+
export type TypertRemoteScopeApi<ContextKey extends string> = {
|
|
134
|
+
[Namespace in TypertRemoteScopeNamespaceKey<ContextKey>]: TypertRemoteScopeNamespace<Namespace, ContextKey>;
|
|
135
|
+
};
|
|
136
|
+
/** Merge-extensible direct namespace surface generated for Client Remote services. */
|
|
137
|
+
export interface TypertRemoteNamespaceMap {
|
|
138
|
+
}
|
|
139
|
+
/** Awaitable disposer returned by Cordis-owned Typert registrations. */
|
|
140
|
+
export type TypertDisposer = () => Promise<void>;
|
|
141
|
+
type StringKeyOf<Value> = Extract<keyof Value, string>;
|
|
142
|
+
/** Minimal runtime-schema capability carried by strict generated codecs. */
|
|
143
|
+
export interface TypertSchema<Output = unknown> {
|
|
144
|
+
/**
|
|
145
|
+
* Parse and validate one boundary value.
|
|
146
|
+
* @param value - untrusted boundary value.
|
|
147
|
+
* @returns the validated value.
|
|
148
|
+
*/
|
|
149
|
+
parse(value: unknown): Output;
|
|
150
|
+
}
|
|
151
|
+
/** Codec attached to one invocation parameter or result. */
|
|
152
|
+
export type TypertCodec = {
|
|
153
|
+
readonly mode: 'strict';
|
|
154
|
+
readonly typeSymbol: string;
|
|
155
|
+
readonly schema: TypertSchema;
|
|
156
|
+
} | {
|
|
157
|
+
readonly mode: 'src-json';
|
|
158
|
+
};
|
|
159
|
+
/** One ordered business parameter in a Remote invocation. */
|
|
160
|
+
export interface InvocationParameterDescriptor {
|
|
161
|
+
/** Source-level parameter name. */
|
|
162
|
+
readonly name: string;
|
|
163
|
+
/** Required key in the wire `args` object. */
|
|
164
|
+
readonly wire: string;
|
|
165
|
+
/** Whether the value is JSON or requires a registered Host lookup. */
|
|
166
|
+
readonly source: 'json' | 'lookup';
|
|
167
|
+
/** Lookup key when `source` is `lookup`. */
|
|
168
|
+
readonly lookup?: string;
|
|
169
|
+
/** Boundary codec for the wire representation. */
|
|
170
|
+
readonly codec: TypertCodec;
|
|
171
|
+
/** Missing wire fields decode to `undefined` only for an explicitly declared `T | undefined`. */
|
|
172
|
+
readonly acceptsUndefined?: true;
|
|
173
|
+
}
|
|
174
|
+
/** Source position retained for diagnostics from generated definitions. */
|
|
175
|
+
export interface InvocationSourceLocation {
|
|
176
|
+
readonly file: string;
|
|
177
|
+
readonly line: number;
|
|
178
|
+
readonly column: number;
|
|
179
|
+
}
|
|
180
|
+
/** Carrier-independent description of one exported method invocation. */
|
|
181
|
+
export interface InvocationDescriptor {
|
|
182
|
+
/** Globally stable generated identity. */
|
|
183
|
+
readonly id: string;
|
|
184
|
+
/** Cordis service key owning the method. */
|
|
185
|
+
readonly service: string;
|
|
186
|
+
/** Wire namespace, defaulting to the service key. */
|
|
187
|
+
readonly namespace: string;
|
|
188
|
+
/** Public instance method name. */
|
|
189
|
+
readonly method: string;
|
|
190
|
+
/** Service member invoked when the exported method name is an alias. */
|
|
191
|
+
readonly implementation?: string;
|
|
192
|
+
/** Absent for unary calls; stream calls validate and deliver every yielded item. */
|
|
193
|
+
readonly mode?: 'stream';
|
|
194
|
+
/** Receiver selection mode. */
|
|
195
|
+
readonly invocation: {
|
|
196
|
+
readonly kind: 'direct';
|
|
197
|
+
} | {
|
|
198
|
+
readonly kind: 'context';
|
|
199
|
+
readonly context: string;
|
|
200
|
+
readonly wire: string;
|
|
201
|
+
readonly codec: TypertCodec;
|
|
202
|
+
};
|
|
203
|
+
/** Optional consuming-Context projection for one direct lookup parameter. */
|
|
204
|
+
readonly scope?: {
|
|
205
|
+
/** Context kind whose Client adapter supplies the identity. */
|
|
206
|
+
readonly context: string;
|
|
207
|
+
/** Lookup parameter wire field replaced by the Context identity. */
|
|
208
|
+
readonly wire: string;
|
|
209
|
+
};
|
|
210
|
+
/** Ordered business parameters. */
|
|
211
|
+
readonly parameters: readonly InvocationParameterDescriptor[];
|
|
212
|
+
/** Transport cancellation injected after business parameters instead of entering wire args. */
|
|
213
|
+
readonly cancellation?: {
|
|
214
|
+
/** Reserved final Host method parameter. */
|
|
215
|
+
readonly parameter: 'signal';
|
|
216
|
+
};
|
|
217
|
+
/** Codec for the unary result or each yielded stream item. */
|
|
218
|
+
readonly result: TypertCodec;
|
|
219
|
+
/** Source declaration used only for diagnostics. */
|
|
220
|
+
readonly sourceLocation?: InvocationSourceLocation;
|
|
221
|
+
}
|
|
222
|
+
/** Generated Host contract selected explicitly by a Client assembly. */
|
|
223
|
+
export interface TypertRemoteContribution {
|
|
224
|
+
/** npm package that owns the Remote methods. */
|
|
225
|
+
readonly package: string;
|
|
226
|
+
/** Consumer-side invocation descriptors generated from that package. */
|
|
227
|
+
readonly descriptors: readonly InvocationDescriptor[];
|
|
228
|
+
}
|
|
229
|
+
/** Client Remote capability implemented by the Gateway and consumed by Remote assemblies. */
|
|
230
|
+
export interface TypertClientRemote extends TypertRemoteNamespaceMap {
|
|
231
|
+
/**
|
|
232
|
+
* Mount one generated Host-for-Client contribution in the caller's fiber.
|
|
233
|
+
* @param contribution - explicitly selected Remote package artifact.
|
|
234
|
+
* @returns disposer after namespace services and concrete methods are ready.
|
|
235
|
+
*/
|
|
236
|
+
$mount(contribution: TypertRemoteContribution): Promise<TypertDisposer>;
|
|
237
|
+
/**
|
|
238
|
+
* Subscribe to one forwarded Host event. Notifications run in registration
|
|
239
|
+
* order and isolate failures; scoped waterfalls return, delegate through
|
|
240
|
+
* `next()`, or reject the Host dispatch.
|
|
241
|
+
* @template Event - forwarded event name selected by the Host assembly.
|
|
242
|
+
* @param event - forwarded Host event name, unchanged on the wire.
|
|
243
|
+
* @param listener - receives the Client projection of the Cordis `Events` declaration.
|
|
244
|
+
* @returns disposer owned by the calling fiber.
|
|
245
|
+
*/
|
|
246
|
+
$on<Event extends TypertRemoteEvent>(event: Event, listener: TypertClientEventListener<Event>): () => void;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Resolve one validated wire identity, synchronously or asynchronously.
|
|
250
|
+
* @param id - validated wire identity.
|
|
251
|
+
* @returns the Host object, or `undefined` when unavailable.
|
|
252
|
+
*/
|
|
253
|
+
export type TypertLookupResolver<Host = unknown, Wire = unknown> = (id: Wire) => Host | undefined | Promise<Host | undefined>;
|
|
254
|
+
/** Runtime provider for one declared Host object lookup. */
|
|
255
|
+
export interface TypertLookupProvider<Host = unknown, Wire = unknown> {
|
|
256
|
+
/** Source parameter name recognized by the SRC weak parser. */
|
|
257
|
+
readonly parameter: string;
|
|
258
|
+
/** Wire field replacing the Host object parameter. */
|
|
259
|
+
readonly wire: string;
|
|
260
|
+
/** Canonical Host type symbol used by strict generation. */
|
|
261
|
+
readonly hostTypeSymbol: string;
|
|
262
|
+
/** Canonical wire type symbol used by strict generation. */
|
|
263
|
+
readonly wireTypeSymbol: string;
|
|
264
|
+
/**
|
|
265
|
+
* Resolve a wire identity through the provider's default policy.
|
|
266
|
+
* @param id - validated wire identity.
|
|
267
|
+
* @returns the object, `undefined` when unavailable, or either asynchronously.
|
|
268
|
+
*/
|
|
269
|
+
resolve(id: Wire): Host | undefined | Promise<Host | undefined>;
|
|
270
|
+
}
|
|
271
|
+
/** Stable wire declaration retained after a lookup provider unloads. */
|
|
272
|
+
export interface TypertLookupDefinition {
|
|
273
|
+
/** Merge-declared lookup key. */
|
|
274
|
+
readonly key: string;
|
|
275
|
+
/** Source parameter name recognized by the SRC weak parser. */
|
|
276
|
+
readonly parameter: string;
|
|
277
|
+
/** Wire field replacing the Host object parameter. */
|
|
278
|
+
readonly wire: string;
|
|
279
|
+
/** Canonical Host type symbol used by strict generation. */
|
|
280
|
+
readonly hostTypeSymbol: string;
|
|
281
|
+
/** Canonical wire type symbol used by strict generation. */
|
|
282
|
+
readonly wireTypeSymbol: string;
|
|
283
|
+
}
|
|
284
|
+
/** Bidirectional projection between one environment's Context and its wire identity. */
|
|
285
|
+
export interface TypertContextAdapter<Wire = unknown> {
|
|
286
|
+
/**
|
|
287
|
+
* Read the identity represented by a live Context.
|
|
288
|
+
* @param ctx - Context in this adapter's environment.
|
|
289
|
+
* @returns the wire identity, or `undefined` when the Context has another kind.
|
|
290
|
+
*/
|
|
291
|
+
identity(ctx: Context): Wire | undefined;
|
|
292
|
+
/**
|
|
293
|
+
* Resolve a wire identity to a live Context in this adapter's environment.
|
|
294
|
+
* An asynchronous Client resolver may wait for its owner to create the Context.
|
|
295
|
+
* @param id - validated wire identity.
|
|
296
|
+
* @returns the Context, or `undefined` when it is unavailable.
|
|
297
|
+
*/
|
|
298
|
+
resolve(id: Wire): Context | undefined | Promise<Context | undefined>;
|
|
299
|
+
}
|
|
300
|
+
/** Host Context adapter plus the wire declaration used by strict Remote methods. */
|
|
301
|
+
export interface TypertHostContextAdapter<Wire = unknown> extends TypertContextAdapter<Wire> {
|
|
302
|
+
/** Wire field carrying the Context identity. */
|
|
303
|
+
readonly wire: string;
|
|
304
|
+
/** Canonical wire type symbol used by strict generation. */
|
|
305
|
+
readonly wireTypeSymbol: string;
|
|
306
|
+
}
|
|
307
|
+
/** Composition-owned resolver replacing one Host Context adapter's default lookup policy. */
|
|
308
|
+
export type TypertHostContextResolver<Wire = unknown> = (id: Wire) => Context | undefined | Promise<Context | undefined>;
|
|
309
|
+
/** Client-side bidirectional Context adapter. */
|
|
310
|
+
export interface TypertClientContextAdapter<Wire = unknown> {
|
|
311
|
+
/**
|
|
312
|
+
* Read the identity represented by a live Client Context.
|
|
313
|
+
* @param ctx - Client Context inspected by a scoped Remote caller.
|
|
314
|
+
* @returns the wire identity, or `undefined` for another Context kind.
|
|
315
|
+
*/
|
|
316
|
+
identity(ctx: Context): Wire | undefined;
|
|
317
|
+
/**
|
|
318
|
+
* Resolve a wire identity from the Client's currently materialized Contexts.
|
|
319
|
+
* @param id - validated wire identity.
|
|
320
|
+
* @returns the Client Context, or `undefined` when unavailable.
|
|
321
|
+
*/
|
|
322
|
+
resolve(id: Wire): Context | undefined;
|
|
323
|
+
}
|
|
324
|
+
/** Host Context identity selected from the registered adapter set. */
|
|
325
|
+
export interface TypertHostContextIdentity {
|
|
326
|
+
/** Merge-declared Context kind whose adapter recognized the Context. */
|
|
327
|
+
readonly kind: string;
|
|
328
|
+
/** Wire identity returned by that adapter. */
|
|
329
|
+
readonly identity: unknown;
|
|
330
|
+
}
|
|
331
|
+
/** Notification emitted after a Typert runtime registry changes. */
|
|
332
|
+
export interface TypertRegistryChange {
|
|
333
|
+
readonly kind: 'local' | 'remote' | 'lookup' | 'host-context' | 'client-context';
|
|
334
|
+
readonly key: string;
|
|
335
|
+
}
|
|
336
|
+
/** Listener for one Typert runtime registry. */
|
|
337
|
+
export type TypertRegistryListener = (change: TypertRegistryChange) => void;
|
|
338
|
+
/** Current-environment invocation definitions. */
|
|
339
|
+
export interface TypertLocalRegistry {
|
|
340
|
+
/**
|
|
341
|
+
* Look up one invocation by `<namespace>/<method>`.
|
|
342
|
+
* @param endpoint - canonical endpoint.
|
|
343
|
+
* @returns the live descriptor, or `undefined` when absent.
|
|
344
|
+
*/
|
|
345
|
+
get(endpoint: string): InvocationDescriptor | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Report whether a strict definition has existed during this Typert Service lifetime.
|
|
348
|
+
* @param endpoint - canonical endpoint.
|
|
349
|
+
* @returns `true` after the endpoint has been registered at least once, even if withdrawn.
|
|
350
|
+
*/
|
|
351
|
+
hasSeen(endpoint: string): boolean;
|
|
352
|
+
/** @returns a registration-order snapshot of local descriptors. */
|
|
353
|
+
list(): readonly InvocationDescriptor[];
|
|
354
|
+
/**
|
|
355
|
+
* Observe later local-definition changes.
|
|
356
|
+
* @param listener - synchronous contained observer.
|
|
357
|
+
* @returns disposer for this subscription.
|
|
358
|
+
*/
|
|
359
|
+
subscribe(listener: TypertRegistryListener): TypertDisposer;
|
|
360
|
+
}
|
|
361
|
+
/** Consumer-selected Remote contribution registry. */
|
|
362
|
+
export interface TypertRemoteRegistry {
|
|
363
|
+
/**
|
|
364
|
+
* Register one generated contribution for the calling Cordis fiber.
|
|
365
|
+
* @param contribution - generated Remote descriptors.
|
|
366
|
+
* @returns disposer withdrawing the exact contribution.
|
|
367
|
+
*/
|
|
368
|
+
register(contribution: TypertRemoteContribution): TypertDisposer;
|
|
369
|
+
/**
|
|
370
|
+
* Look up one Remote descriptor by endpoint.
|
|
371
|
+
* @param endpoint - canonical endpoint.
|
|
372
|
+
* @returns the descriptor, or `undefined` when unmounted.
|
|
373
|
+
*/
|
|
374
|
+
get(endpoint: string): InvocationDescriptor | undefined;
|
|
375
|
+
/** @returns a registration-order snapshot of Remote descriptors. */
|
|
376
|
+
list(): readonly InvocationDescriptor[];
|
|
377
|
+
/**
|
|
378
|
+
* Observe later Remote contribution changes.
|
|
379
|
+
* @param listener - synchronous contained observer.
|
|
380
|
+
* @returns disposer for this subscription.
|
|
381
|
+
*/
|
|
382
|
+
subscribe(listener: TypertRegistryListener): TypertDisposer;
|
|
383
|
+
}
|
|
384
|
+
/** Runtime registry for Host object lookup providers. */
|
|
385
|
+
export interface TypertLookupRegistry {
|
|
386
|
+
/**
|
|
387
|
+
* Register one provider under its merge-declared key.
|
|
388
|
+
* @param key - lookup key.
|
|
389
|
+
* @param provider - owning package's live resolver.
|
|
390
|
+
* @returns disposer withdrawing the exact provider.
|
|
391
|
+
*/
|
|
392
|
+
register<K extends StringKeyOf<TypertLookupMap>>(key: K, provider: TypertLookupProvider<TypertLookupHost<TypertLookupMap[K]>, TypertLookupWire<TypertLookupMap[K]>>): TypertDisposer;
|
|
393
|
+
/**
|
|
394
|
+
* Replace one provider's default resolution policy while this contribution is active.
|
|
395
|
+
* Configuration may precede provider registration; without a live provider, `get()` remains unavailable.
|
|
396
|
+
* @param key - lookup key whose wire declaration remains provider-owned.
|
|
397
|
+
* @param resolver - composition-owned resolver used by every lookup of this key.
|
|
398
|
+
* @returns disposer restoring the provider's default resolver.
|
|
399
|
+
*/
|
|
400
|
+
configure<K extends StringKeyOf<TypertLookupMap>>(key: K, resolver: TypertLookupResolver<TypertLookupHost<TypertLookupMap[K]>, TypertLookupWire<TypertLookupMap[K]>>): TypertDisposer;
|
|
401
|
+
/**
|
|
402
|
+
* Look up one provider by runtime key.
|
|
403
|
+
* @param key - descriptor lookup key.
|
|
404
|
+
* @returns the live provider, or `undefined` when absent.
|
|
405
|
+
*/
|
|
406
|
+
get(key: string): TypertLookupProvider | undefined;
|
|
407
|
+
/** @returns lookup declarations observed during this Typert Service lifetime. */
|
|
408
|
+
definitions(): readonly TypertLookupDefinition[];
|
|
409
|
+
/** @returns a snapshot of registered provider keys. */
|
|
410
|
+
keys(): readonly string[];
|
|
411
|
+
/**
|
|
412
|
+
* Observe later lookup changes.
|
|
413
|
+
* @param listener - synchronous contained observer.
|
|
414
|
+
* @returns disposer for this subscription.
|
|
415
|
+
*/
|
|
416
|
+
subscribe(listener: TypertRegistryListener): TypertDisposer;
|
|
417
|
+
}
|
|
418
|
+
/** Runtime registry for the Host and Client adapters of each Context kind. */
|
|
419
|
+
export interface TypertContextRegistry {
|
|
420
|
+
/**
|
|
421
|
+
* Register a Host Context adapter.
|
|
422
|
+
* @param key - merge-declared Context key.
|
|
423
|
+
* @param adapter - owning package's bidirectional Host projection.
|
|
424
|
+
* @returns disposer withdrawing the exact adapter.
|
|
425
|
+
*/
|
|
426
|
+
registerHost<K extends StringKeyOf<TypertContextMap>>(key: K, adapter: TypertHostContextAdapter<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
|
|
427
|
+
/**
|
|
428
|
+
* Override one Host Context key's resolution policy for the calling fiber.
|
|
429
|
+
* Configuration may precede provider registration and restores the provider's default resolver on disposal.
|
|
430
|
+
* @param key - merge-declared Context key.
|
|
431
|
+
* @param resolver - composition-owned resolver used by every Host Context lookup of this key.
|
|
432
|
+
* @returns disposer restoring the provider's default resolver.
|
|
433
|
+
*/
|
|
434
|
+
configureHost<K extends StringKeyOf<TypertContextMap>>(key: K, resolver: TypertHostContextResolver<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
|
|
435
|
+
/**
|
|
436
|
+
* Register a Client Context adapter.
|
|
437
|
+
* @param key - merge-declared Context key.
|
|
438
|
+
* @param adapter - owning package's bidirectional Client projection.
|
|
439
|
+
* @returns disposer withdrawing the exact adapter.
|
|
440
|
+
*/
|
|
441
|
+
registerClient<K extends StringKeyOf<TypertContextMap>>(key: K, adapter: TypertClientContextAdapter<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
|
|
442
|
+
/**
|
|
443
|
+
* Identify a live Host Context through the sole registered adapter set.
|
|
444
|
+
* @param ctx - Context projected by a Host-to-Client scoped event.
|
|
445
|
+
* @returns its kind and wire identity, or `undefined` when no adapter recognizes it.
|
|
446
|
+
* @throws when more than one Context kind recognizes the same Context.
|
|
447
|
+
*/
|
|
448
|
+
identifyHost(ctx: Context): TypertHostContextIdentity | undefined;
|
|
449
|
+
/**
|
|
450
|
+
* Look up a Host Context adapter.
|
|
451
|
+
* @param key - descriptor Context key.
|
|
452
|
+
* @returns the adapter, or `undefined` when absent.
|
|
453
|
+
*/
|
|
454
|
+
getHost(key: string): TypertHostContextAdapter | undefined;
|
|
455
|
+
/**
|
|
456
|
+
* Look up a Client Context adapter.
|
|
457
|
+
* @param key - descriptor Context key.
|
|
458
|
+
* @returns the adapter, or `undefined` when absent.
|
|
459
|
+
*/
|
|
460
|
+
getClient(key: string): TypertClientContextAdapter | undefined;
|
|
461
|
+
/**
|
|
462
|
+
* Observe later Context adapter changes.
|
|
463
|
+
* @param listener - synchronous contained observer.
|
|
464
|
+
* @returns disposer for this subscription.
|
|
465
|
+
*/
|
|
466
|
+
subscribe(listener: TypertRegistryListener): TypertDisposer;
|
|
467
|
+
}
|
|
468
|
+
/** Minimal Typert runtime consumed through dependency inversion. */
|
|
469
|
+
export interface TypertRegistryContract {
|
|
470
|
+
readonly local: TypertLocalRegistry;
|
|
471
|
+
readonly remotes: TypertRemoteRegistry;
|
|
472
|
+
readonly lookups: TypertLookupRegistry;
|
|
473
|
+
readonly contexts: TypertContextRegistry;
|
|
474
|
+
}
|
|
475
|
+
declare module '@deepseek-ai/cordis' {
|
|
476
|
+
interface Context {
|
|
477
|
+
typert: TypertRegistryContract;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
export {};
|
|
481
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x1a0f3n9/dsh-typert-protocol",
|
|
3
|
+
"description": "Compiler-independent Remote metadata and Typert provider protocols",
|
|
4
|
+
"version": "0.1.2-alpha.6",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/typert/protocol"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./types": {
|
|
22
|
+
"types": "./lib/types/types.d.ts",
|
|
23
|
+
"default": "./lib/types/types.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/types/**/*.js",
|
|
31
|
+
"lib/types/**/*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
39
|
+
}
|
|
40
|
+
}
|