@deepseek-ai/dsh-typert-protocol 0.0.1-rc.3

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 ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, DeepSeek
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/typert/protocol/README.md
5
+ README.md: 84f9f1b31cca35cffce5dc5fc84db1017adaad08
6
+ README.zh.md: 97e4734a7292f0a305ff8ed00ff1d72d1a53b5e9
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @deepseek-ai/dsh-typert-protocol
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ Compiler-independent declarations shared by business packages, generated Typert artifacts, the Host Gateway, and Client API. This package owns the Remote Service base, decorators, explicit binding fallback, merge-extensible protocol maps, invocation descriptors, codecs, and provider contracts; it does not run TypeScript analysis or register a concrete Cordis service.
6
+
7
+ ## Remote declarations
8
+
9
+ - `@Remote` marks a public instance method for direct invocation on its registered Cordis Service.
10
+ - `@RemoteScope(key)` marks a method whose receiver is selected from a merge-declared scoped Context kind.
11
+ - `TypertRemoteService` binds the Cordis key passed to `super(ctx, serviceKey, options?)` to the same default wire namespace.
12
+ - `bindTypertRemote(this, serviceKey, options?)` provides the same visible, frozen binding for a Service that cannot inherit from `TypertRemoteService`.
13
+ - `remoteMethods(service)` returns a detached declaration-order snapshot used by the Gateway's SRC fallback.
14
+
15
+ A Host method opts into cooperative cancellation by declaring `signal: AbortSignal` as its final parameter. `InvocationDescriptor.cancellation` records that reserved injection point; the signal never becomes a JSON parameter or lookup field. SRC recognizes the final parameter name, while strict generation also verifies the global `AbortSignal` type.
16
+
17
+ Decorator initializers retain markers in a module-private `WeakMap` keyed by the Service prototype. They do not add constructor symbols, prototype properties, parameter metadata, or runtime reflection fields. A `TypertRemoteService` exposes the same public readonly `typertRemote` binding that the explicit helper returns.
18
+
19
+ ## Typert protocol
20
+
21
+ Business packages extend `TypertLookupMap` and `TypertContextMap` to associate Host objects or scoped Contexts with their wire identities. Generated artifacts extend `TypertRemoteMap`, `TypertRemoteScopeMap`, and `TypertRemoteNamespaceMap` so Client imports expose only selected Remote methods. `InvocationDescriptor` is the shared runtime form consumed by the registry, Gateway, and Client Remote.
22
+
23
+ The Host assembly extends `TypertRemoteEventSelection` with the Host events it forwards to consumers, which narrows the `ctx.remote.$on` key face; `TypertForwardableEvent` states the shapes a one-way delivery can carry at all, excluding Scope-bound and answered events. `TypertClientRemote` carries both roles of that surface: consumers subscribe through `$on`, and the Client half owning the host frame sink hands frames over through `$dispatch`.
24
+
25
+ Lookup and Context packages own both sides of their contract: declaration merging supplies the static association, while runtime providers register identity resolution with `ctx.typert`. A lookup or Host Context provider supplies the stable declaration and default resolver, while Host composition may separately configure a synchronous or asynchronous resolver; policy rejections may use `TypertLookupFailure` to carry a failure value owned by the boundary adapter. Strict codecs carry generated schemas; `src-json` codecs identify the weaker source-launch path.
26
+
27
+ ## Model Experience
28
+
29
+ None, as this protocol package declares application reflection and registers nothing model-facing.
30
+
31
+ #### KV Cache effect
32
+
33
+ No direct effect.
34
+
35
+ ## Known Limitations and Deferred Work
36
+
37
+ - Decorator markers contain only the method name and direct or Context invocation mode. Parameter, result, lookup, and schema reflection require the Typert build pipeline.
38
+ - Remote decorators accept only public, non-static instance methods with string names. SRC execution cannot represent overloaded, destructured, defaulted, or rest-parameter signatures.
package/README.zh.md ADDED
@@ -0,0 +1,38 @@
1
+ # @deepseek-ai/dsh-typert-protocol
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 该包提供不依赖编译器的声明,由业务包、生成的 Typert 产物、宿主网关和客户端 API 共享。它负责 Remote 服务基类、装饰器、显式绑定回退、可通过声明合并扩展的协议映射、调用描述符、编解码器和提供方约定;它不执行 TypeScript 分析,也不注册具体 Cordis 服务。
6
+
7
+ ## Remote 声明
8
+
9
+ - `@Remote` 将公开实例方法标记为可在其注册的 Cordis 服务上直接调用。
10
+ - `@RemoteScope(key)` 标记接收者选自合并声明的作用域 Context 类型的方法。
11
+ - `TypertRemoteService` 将传给 `super(ctx, serviceKey, options?)` 的 Cordis 键绑定到同一默认协议命名空间。
12
+ - `bindTypertRemote(this, serviceKey, options?)` 为无法继承 `TypertRemoteService` 的服务提供同样可见且冻结的绑定。
13
+ - `remoteMethods(service)` 返回按声明顺序排列、与内部状态分离的快照,供 Gateway 的 SRC 回退路径使用。
14
+
15
+ 宿主方法通过将 `signal: AbortSignal` 声明为最后一个参数来启用协作式取消。`InvocationDescriptor.cancellation` 记录这个保留的注入点;该信号绝不会成为 JSON 参数或查找字段。SRC 识别末位参数名,严格生成还会校验它是否具有全局 `AbortSignal` 类型。
16
+
17
+ 装饰器初始化器将标记保存在以服务原型为键的模块私有 `WeakMap` 中。它们不会在构造函数上添加符号,也不会添加原型属性、参数元数据或运行时反射字段。`TypertRemoteService` 会暴露与显式辅助函数相同的公开只读 `typertRemote` 绑定。
18
+
19
+ ## Typert 协议
20
+
21
+ 业务包扩展 `TypertLookupMap` 和 `TypertContextMap`,以关联宿主对象或作用域 Context 与其协议身份。生成的产物扩展 `TypertRemoteMap`、`TypertRemoteScopeMap` 和 `TypertRemoteNamespaceMap`,使客户端导入后仅暴露选定的 Remote 方法。`InvocationDescriptor` 是供注册表、网关和客户端 Remote 使用的共享运行时形式。
22
+
23
+ Host 装配以转发给消费端的 Host 事件扩展 `TypertRemoteEventSelection`,从而收窄 `ctx.remote.$on` 的键面;`TypertForwardableEvent` 陈述单向投递根本能承载哪些形状,把 Scope 化事件与有返回值的事件排除在外。`TypertClientRemote` 承载该面的两种角色:消费方经 `$on` 订阅,持有 Host 帧 sink 的 Client 半经 `$dispatch` 交出帧。
24
+
25
+ 查找包与 Context 包同时负责该约定的两侧:声明合并提供静态关联,运行时提供方则向 `ctx.typert` 注册身份解析。查找提供方或宿主 Context 提供方提供稳定声明与默认解析器,宿主组合可以另行配置同步或异步解析器;策略拒绝可用 `TypertLookupFailure` 携带由边界适配器拥有的失败值。严格编解码器携带生成的 schema;`src-json` 编解码器标识约束更弱的源码启动路径。
26
+
27
+ ## 模型体验
28
+
29
+ 无,因为该协议包声明应用反射,不注册任何面向模型的内容。
30
+
31
+ #### KV Cache 影响
32
+
33
+ 无直接影响。
34
+
35
+ ## 已知限制与暂缓事项
36
+
37
+ - 装饰器标记仅包含方法名,以及直接调用或 Context 调用模式。参数、结果、查找和 schema 反射需要 Typert 构建流水线。
38
+ - Remote 装饰器只接受具有字符串名称的公开、非静态实例方法。SRC 执行无法表示重载签名,以及包含解构参数、默认参数或剩余参数的方法签名。
package/lib/index.js ADDED
@@ -0,0 +1,140 @@
1
+ import { Service } from "@deepseek-ai/cordis";
2
+ //#region lib/types/index.js
3
+ /**
4
+ * Remote decorators and explicit Gateway bindings backed only by private
5
+ * module state. Strict reflection remains a Typert compiler responsibility.
6
+ * @module @deepseek-ai/dsh-typert-protocol
7
+ */
8
+ const TYPERT_REMOTE_SEGMENT_PATTERN = /^[A-Za-z0-9_$.-]+$/;
9
+ /**
10
+ * Test one generated Remote name against the Connection endpoint grammar.
11
+ * @param value - namespace, method, lookup, or Context segment.
12
+ * @returns whether the value can cross the shared RPC carrier unchanged.
13
+ */
14
+ function isTypertRemoteSegment(value) {
15
+ return value !== "." && value !== ".." && TYPERT_REMOTE_SEGMENT_PATTERN.test(value);
16
+ }
17
+ /**
18
+ * A lookup policy rejection whose typed payload belongs to the active boundary adapter.
19
+ * Gateway adapters preserve this payload instead of collapsing it into an infrastructure failure.
20
+ */
21
+ var TypertLookupFailure = class extends Error {
22
+ /** Adapter-owned failure returned to the caller. */
23
+ failure;
24
+ /**
25
+ * Wrap one adapter failure without exposing the rejected identity.
26
+ * @param failure - typed failure owned by the active boundary adapter.
27
+ */
28
+ constructor(failure) {
29
+ super("Typert lookup policy rejected the requested identity");
30
+ this.name = "TypertLookupFailure";
31
+ this.failure = failure;
32
+ }
33
+ };
34
+ const markers = /* @__PURE__ */ new WeakMap();
35
+ /**
36
+ * Bind one visible Service field to a Cordis key and Remote namespace.
37
+ * @param service - owning Service instance, normally `this`.
38
+ * @param serviceKey - exact Cordis service key.
39
+ * @param options - optional distinct wire namespace.
40
+ * @returns a frozen, inspectable binding with no compiler-injected metadata.
41
+ */
42
+ function bindTypertRemote(service, serviceKey, options = {}) {
43
+ validateName("service key", serviceKey);
44
+ const namespace = options.namespace ?? serviceKey;
45
+ validateName("namespace", namespace);
46
+ return Object.freeze({
47
+ service,
48
+ serviceKey,
49
+ namespace
50
+ });
51
+ }
52
+ /** Cordis Service base that exposes its registered name through Typert Gateway. */
53
+ var TypertRemoteService = class extends Service {
54
+ /** Visible binding consumed by the Gateway's source-mode discovery. */
55
+ typertRemote;
56
+ /**
57
+ * Register the Service and bind the same key to Typert Gateway.
58
+ * @param ctx - owning Cordis Context.
59
+ * @param serviceKey - exact Cordis service key and default wire namespace.
60
+ * @param options - optional distinct wire namespace.
61
+ */
62
+ constructor(ctx, serviceKey, options = {}) {
63
+ super(ctx, serviceKey);
64
+ this.typertRemote = bindTypertRemote(this, this.name, options);
65
+ }
66
+ };
67
+ function Remote(methodOrExportName, context) {
68
+ if (typeof methodOrExportName === "string") {
69
+ validateName("Remote export name", methodOrExportName);
70
+ return function(_method, decoratorContext) {
71
+ addMarkerInitializer(decoratorContext, { kind: "direct" }, methodOrExportName);
72
+ };
73
+ }
74
+ if (context === void 0) throw new TypeError("typert-protocol: Remote decorator context is missing");
75
+ addMarkerInitializer(context, { kind: "direct" });
76
+ }
77
+ /**
78
+ * Create a decorator for a method resolved from one Remote Scope.
79
+ * @param key - scope key declared through the Context map.
80
+ * @param exportName - optional Remote export name; defaults to the method name.
81
+ * @returns a standard method decorator that records only private module state.
82
+ */
83
+ function RemoteScope(key, exportName) {
84
+ validateName("Scope key", key);
85
+ if (exportName !== void 0) validateName("Remote export name", exportName);
86
+ return function(_method, context) {
87
+ addMarkerInitializer(context, {
88
+ kind: "context",
89
+ context: key
90
+ }, exportName);
91
+ };
92
+ }
93
+ /**
94
+ * Read Remote markers attached to a live Service by decorator initializers.
95
+ * The returned snapshot cannot mutate the private marker table.
96
+ * @param service - live Service instance.
97
+ * @returns markers in class declaration order.
98
+ */
99
+ function remoteMethods(service) {
100
+ const prototype = Object.getPrototypeOf(service);
101
+ if (prototype === null) return [];
102
+ return [...markers.get(prototype) ?? []].map(([method, marker]) => ({
103
+ method,
104
+ ...marker
105
+ }));
106
+ }
107
+ function addMarkerInitializer(context, invocation, exportName) {
108
+ if (context.private || context.static || typeof context.name !== "string") throw new TypeError("typert-protocol: Remote decorators require a public instance method with a string name");
109
+ const method = context.name;
110
+ context.addInitializer(function() {
111
+ const prototype = Object.getPrototypeOf(this);
112
+ if (prototype === null) throw new TypeError(`typert-protocol: cannot mark Remote method "${method}" on an object without a prototype`);
113
+ mark(prototype, method, invocation, exportName);
114
+ });
115
+ }
116
+ function mark(prototype, method, invocation, exportName) {
117
+ let table = markers.get(prototype);
118
+ if (table === void 0) {
119
+ table = /* @__PURE__ */ new Map();
120
+ markers.set(prototype, table);
121
+ }
122
+ const marker = {
123
+ ...exportName === void 0 || exportName === method ? {} : { exportName },
124
+ invocation: Object.freeze(invocation)
125
+ };
126
+ const current = table.get(method);
127
+ if (current !== void 0) {
128
+ if (current.exportName === marker.exportName && sameInvocation(current.invocation, invocation)) return;
129
+ throw new Error(`typert-protocol: Remote method "${method}" has conflicting invocation markers`);
130
+ }
131
+ table.set(method, Object.freeze(marker));
132
+ }
133
+ function sameInvocation(left, right) {
134
+ return left.kind === right.kind && (left.kind === "direct" || right.kind === "context" && left.context === right.context);
135
+ }
136
+ function validateName(subject, value) {
137
+ if (!isTypertRemoteSegment(value)) throw new TypeError(`typert-protocol: ${subject} must contain only RPC endpoint segment characters`);
138
+ }
139
+ //#endregion
140
+ export { Remote, RemoteScope, TypertLookupFailure, TypertRemoteService, bindTypertRemote, isTypertRemoteSegment, remoteMethods };
@@ -0,0 +1,23 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@deepseek-ai/dsh-typert-protocol`.
4
+ * @module @deepseek-ai/dsh-typert-protocol/invariant
5
+ */
6
+ const PACKAGE_NAME = "@deepseek-ai/dsh-typert-protocol";
7
+ /** Cordis companion plugin name. */
8
+ const name = "typert-protocol-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: decorators retain private immutable declarations and
13
+ * bindings are frozen values with no independent event stream to cross-check.
14
+ */
15
+ const install = () => {};
16
+ /**
17
+ * Register this package's invariant companion.
18
+ * @param ctx - Cordis context carrying the invariant service.
19
+ * @returns the installed registration's disposer after setup succeeds.
20
+ */
21
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
22
+ //#endregion
23
+ export { apply, inject, name };
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Remote decorators and explicit Gateway bindings backed only by private
3
+ * module state. Strict reflection remains a Typert compiler responsibility.
4
+ * @module @deepseek-ai/dsh-typert-protocol
5
+ */
6
+ import { Service, type Context } from '@deepseek-ai/cordis';
7
+ import type { TypertContextMap } from './types.ts';
8
+ /**
9
+ * Test one generated Remote name against the Connection endpoint grammar.
10
+ * @param value - namespace, method, lookup, or Context segment.
11
+ * @returns whether the value can cross the shared RPC carrier unchanged.
12
+ */
13
+ export declare function isTypertRemoteSegment(value: string): boolean;
14
+ /**
15
+ * A lookup policy rejection whose typed payload belongs to the active boundary adapter.
16
+ * Gateway adapters preserve this payload instead of collapsing it into an infrastructure failure.
17
+ */
18
+ export declare class TypertLookupFailure<Failure = unknown> extends Error {
19
+ /** Adapter-owned failure returned to the caller. */
20
+ readonly failure: Failure;
21
+ /**
22
+ * Wrap one adapter failure without exposing the rejected identity.
23
+ * @param failure - typed failure owned by the active boundary adapter.
24
+ */
25
+ constructor(failure: Failure);
26
+ }
27
+ export type { InvocationDescriptor, InvocationParameterDescriptor, InvocationSourceLocation, RemoteFailure, RemoteResult, TypertClientRemote, TypertClientContextBinder, TypertCodec, TypertContext, TypertContextMap, TypertContextRegistry, TypertContextWire, TypertDisposer, TypertForwardableEvent, TypertHostContextProvider, TypertHostContextResolver, TypertLocalRegistry, TypertLookup, TypertLookupDefinition, TypertLookupHost, TypertLookupMap, TypertLookupProvider, TypertLookupResolver, TypertLookupRegistry, TypertLookupWire, TypertRemoteScopeApi, TypertRemoteScopeMap, TypertRemoteScopeNamespace, TypertRemoteContribution, TypertRemoteEvent, TypertRemoteEventSelection, TypertRemoteMap, TypertRemoteNamespace, TypertRemoteNamespaceMap, TypertRemoteRegistry, TypertRegistryChange, TypertRegistryListener, TypertSchema, TypertRegistryContract, } from './types.ts';
28
+ /** Options for an explicit Service-to-Gateway binding. */
29
+ export interface TypertGatewayBindingOptions {
30
+ /** Wire namespace; defaults to the Cordis service key. */
31
+ readonly namespace?: string;
32
+ }
33
+ /** Visible declaration that one Service participates in Typert Gateway export. */
34
+ export interface TypertGatewayBinding<Service extends object = object> {
35
+ readonly service: Service;
36
+ readonly serviceKey: string;
37
+ readonly namespace: string;
38
+ }
39
+ /** Invocation mode recorded by a Remote method decorator. */
40
+ export type RemoteInvocationMarker = {
41
+ readonly kind: 'direct';
42
+ } | {
43
+ readonly kind: 'context';
44
+ readonly context: string;
45
+ };
46
+ /** One decorator marker discovered for a live Service instance. */
47
+ export interface RemoteMethodMarker {
48
+ /** Public instance method carrying the implementation. */
49
+ readonly method: string;
50
+ /** Endpoint method when it differs from the implementation member. */
51
+ readonly exportName?: string;
52
+ readonly invocation: RemoteInvocationMarker;
53
+ }
54
+ type RemoteMethodDecorator = <This extends object, Args extends unknown[], Result>(method: (this: This, ...args: Args) => Result, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Result>) => void;
55
+ /**
56
+ * Bind one visible Service field to a Cordis key and Remote namespace.
57
+ * @param service - owning Service instance, normally `this`.
58
+ * @param serviceKey - exact Cordis service key.
59
+ * @param options - optional distinct wire namespace.
60
+ * @returns a frozen, inspectable binding with no compiler-injected metadata.
61
+ */
62
+ export declare function bindTypertRemote<Service extends object>(service: Service, serviceKey: string, options?: TypertGatewayBindingOptions): TypertGatewayBinding<Service>;
63
+ /** Cordis Service base that exposes its registered name through Typert Gateway. */
64
+ export declare abstract class TypertRemoteService<out T = never> extends Service<T> {
65
+ /** Visible binding consumed by the Gateway's source-mode discovery. */
66
+ readonly typertRemote: TypertGatewayBinding<this>;
67
+ /**
68
+ * Register the Service and bind the same key to Typert Gateway.
69
+ * @param ctx - owning Cordis Context.
70
+ * @param serviceKey - exact Cordis service key and default wire namespace.
71
+ * @param options - optional distinct wire namespace.
72
+ */
73
+ protected constructor(ctx: Context, serviceKey: string, options?: TypertGatewayBindingOptions);
74
+ }
75
+ /**
76
+ * Mark one public instance method as a direct Remote invocation.
77
+ * @param _method - decorated method; retained only by the class itself.
78
+ * @param context - standard decorator context used to schedule private marking.
79
+ */
80
+ export declare function Remote<This extends object, Args extends unknown[], Result>(_method: (this: This, ...args: Args) => Result, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Result>): void;
81
+ /**
82
+ * Mark one public instance method under a distinct exported method name.
83
+ * @param exportName - Remote endpoint method, without a namespace or slash.
84
+ * @returns a standard method decorator.
85
+ */
86
+ export declare function Remote(exportName: string): RemoteMethodDecorator;
87
+ /**
88
+ * Create a decorator for a method resolved from one Remote Scope.
89
+ * @param key - scope key declared through the Context map.
90
+ * @param exportName - optional Remote export name; defaults to the method name.
91
+ * @returns a standard method decorator that records only private module state.
92
+ */
93
+ export declare function RemoteScope(key: Extract<keyof TypertContextMap, string>, exportName?: string): RemoteMethodDecorator;
94
+ /**
95
+ * Read Remote markers attached to a live Service by decorator initializers.
96
+ * The returned snapshot cannot mutate the private marker table.
97
+ * @param service - live Service instance.
98
+ * @returns markers in class declaration order.
99
+ */
100
+ export declare function remoteMethods(service: object): readonly RemoteMethodMarker[];
101
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Remote decorators and explicit Gateway bindings backed only by private
3
+ * module state. Strict reflection remains a Typert compiler responsibility.
4
+ * @module @deepseek-ai/dsh-typert-protocol
5
+ */
6
+ import { Service } from '@deepseek-ai/cordis';
7
+ const TYPERT_REMOTE_SEGMENT_PATTERN = /^[A-Za-z0-9_$.-]+$/;
8
+ /**
9
+ * Test one generated Remote name against the Connection endpoint grammar.
10
+ * @param value - namespace, method, lookup, or Context segment.
11
+ * @returns whether the value can cross the shared RPC carrier unchanged.
12
+ */
13
+ export function isTypertRemoteSegment(value) {
14
+ return value !== '.' && value !== '..' && TYPERT_REMOTE_SEGMENT_PATTERN.test(value);
15
+ }
16
+ /**
17
+ * A lookup policy rejection whose typed payload belongs to the active boundary adapter.
18
+ * Gateway adapters preserve this payload instead of collapsing it into an infrastructure failure.
19
+ */
20
+ export class TypertLookupFailure extends Error {
21
+ /** Adapter-owned failure returned to the caller. */
22
+ failure;
23
+ /**
24
+ * Wrap one adapter failure without exposing the rejected identity.
25
+ * @param failure - typed failure owned by the active boundary adapter.
26
+ */
27
+ constructor(failure) {
28
+ super('Typert lookup policy rejected the requested identity');
29
+ this.name = 'TypertLookupFailure';
30
+ this.failure = failure;
31
+ }
32
+ }
33
+ const markers = new WeakMap();
34
+ /**
35
+ * Bind one visible Service field to a Cordis key and Remote namespace.
36
+ * @param service - owning Service instance, normally `this`.
37
+ * @param serviceKey - exact Cordis service key.
38
+ * @param options - optional distinct wire namespace.
39
+ * @returns a frozen, inspectable binding with no compiler-injected metadata.
40
+ */
41
+ export function bindTypertRemote(service, serviceKey, options = {}) {
42
+ validateName('service key', serviceKey);
43
+ const namespace = options.namespace ?? serviceKey;
44
+ validateName('namespace', namespace);
45
+ return Object.freeze({ service, serviceKey, namespace });
46
+ }
47
+ /** Cordis Service base that exposes its registered name through Typert Gateway. */
48
+ export class TypertRemoteService extends Service {
49
+ /** Visible binding consumed by the Gateway's source-mode discovery. */
50
+ typertRemote;
51
+ /**
52
+ * Register the Service and bind the same key to Typert Gateway.
53
+ * @param ctx - owning Cordis Context.
54
+ * @param serviceKey - exact Cordis service key and default wire namespace.
55
+ * @param options - optional distinct wire namespace.
56
+ */
57
+ constructor(ctx, serviceKey, options = {}) {
58
+ super(ctx, serviceKey);
59
+ this.typertRemote = bindTypertRemote(this, this.name, options);
60
+ }
61
+ }
62
+ export function Remote(methodOrExportName, context) {
63
+ if (typeof methodOrExportName === 'string') {
64
+ validateName('Remote export name', methodOrExportName);
65
+ return function (_method, decoratorContext) {
66
+ addMarkerInitializer(decoratorContext, { kind: 'direct' }, methodOrExportName);
67
+ };
68
+ }
69
+ if (context === undefined)
70
+ throw new TypeError('typert-protocol: Remote decorator context is missing');
71
+ addMarkerInitializer(context, { kind: 'direct' });
72
+ }
73
+ /**
74
+ * Create a decorator for a method resolved from one Remote Scope.
75
+ * @param key - scope key declared through the Context map.
76
+ * @param exportName - optional Remote export name; defaults to the method name.
77
+ * @returns a standard method decorator that records only private module state.
78
+ */
79
+ export function RemoteScope(key, exportName) {
80
+ validateName('Scope key', key);
81
+ if (exportName !== undefined)
82
+ validateName('Remote export name', exportName);
83
+ return function (_method, context) {
84
+ addMarkerInitializer(context, { kind: 'context', context: key }, exportName);
85
+ };
86
+ }
87
+ /**
88
+ * Read Remote markers attached to a live Service by decorator initializers.
89
+ * The returned snapshot cannot mutate the private marker table.
90
+ * @param service - live Service instance.
91
+ * @returns markers in class declaration order.
92
+ */
93
+ export function remoteMethods(service) {
94
+ const prototype = Object.getPrototypeOf(service);
95
+ if (prototype === null)
96
+ return [];
97
+ return [...(markers.get(prototype) ?? [])].map(([method, marker]) => ({ method, ...marker }));
98
+ }
99
+ function addMarkerInitializer(context, invocation, exportName) {
100
+ if (context.private || context.static || typeof context.name !== 'string') {
101
+ throw new TypeError('typert-protocol: Remote decorators require a public instance method with a string name');
102
+ }
103
+ const method = context.name;
104
+ context.addInitializer(function () {
105
+ const prototype = Object.getPrototypeOf(this);
106
+ if (prototype === null) {
107
+ throw new TypeError(`typert-protocol: cannot mark Remote method "${method}" on an object without a prototype`);
108
+ }
109
+ mark(prototype, method, invocation, exportName);
110
+ });
111
+ }
112
+ function mark(prototype, method, invocation, exportName) {
113
+ let table = markers.get(prototype);
114
+ if (table === undefined) {
115
+ table = new Map();
116
+ markers.set(prototype, table);
117
+ }
118
+ const marker = {
119
+ ...(exportName === undefined || exportName === method ? {} : { exportName }),
120
+ invocation: Object.freeze(invocation),
121
+ };
122
+ const current = table.get(method);
123
+ if (current !== undefined) {
124
+ if (current.exportName === marker.exportName && sameInvocation(current.invocation, invocation))
125
+ return;
126
+ throw new Error(`typert-protocol: Remote method "${method}" has conflicting invocation markers`);
127
+ }
128
+ table.set(method, Object.freeze(marker));
129
+ }
130
+ function sameInvocation(left, right) {
131
+ return left.kind === right.kind
132
+ && (left.kind === 'direct' || (right.kind === 'context' && left.context === right.context));
133
+ }
134
+ function validateName(subject, value) {
135
+ if (!isTypertRemoteSegment(value)) {
136
+ throw new TypeError(`typert-protocol: ${subject} must contain only RPC endpoint segment characters`);
137
+ }
138
+ }
139
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@deepseek-ai/dsh-typert-protocol`.
3
+ * @module @deepseek-ai/dsh-typert-protocol/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "typert-protocol-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Package-owned invariant companion for `@deepseek-ai/dsh-typert-protocol`.
3
+ * @module @deepseek-ai/dsh-typert-protocol/invariant
4
+ */
5
+ const PACKAGE_NAME = '@deepseek-ai/dsh-typert-protocol';
6
+ /** Cordis companion plugin name. */
7
+ export const name = 'typert-protocol-invariant';
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export const inject = ['invariants'];
10
+ /**
11
+ * No runtime invariant: decorators retain private immutable declarations and
12
+ * bindings are frozen values with no independent event stream to cross-check.
13
+ */
14
+ const install = () => { };
15
+ /**
16
+ * Register this package's invariant companion.
17
+ * @param ctx - Cordis context carrying the invariant service.
18
+ * @returns the installed registration's disposer after setup succeeds.
19
+ */
20
+ export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
21
+ /* jscpd:ignore-end */
22
+ //# sourceMappingURL=invariant.js.map
@@ -0,0 +1,419 @@
1
+ /**
2
+ * Compiler-independent Typert protocol shared by business packages, generated
3
+ * Remote artifacts, the Host Gateway, and Client API implementations.
4
+ * @module @deepseek-ai/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
+ * One Remote call's failure as the carrier reported it. `code` stays open here:
36
+ * the closed RPC code union belongs to the carrier package, which already
37
+ * depends on this one, so naming it would invert that edge.
38
+ */
39
+ export interface RemoteFailure {
40
+ readonly code: string;
41
+ readonly message: string;
42
+ readonly details: object;
43
+ }
44
+ /**
45
+ * What every generated Remote method resolves to. The Remote face itself folds
46
+ * carrier failures into the error branch, so no consumer wraps a call to
47
+ * recover one; only assembly faults (arity, an unmounted method, a missing
48
+ * Context binder) still reject.
49
+ * @template T - the Host method's business result.
50
+ */
51
+ export type RemoteResult<T> = {
52
+ readonly ok: true;
53
+ readonly value: T;
54
+ } | {
55
+ readonly ok: false;
56
+ readonly error: RemoteFailure;
57
+ };
58
+ /** Merge-extensible scoped Remote method signatures generated for consumers. */
59
+ export interface TypertRemoteScopeMap {
60
+ }
61
+ /**
62
+ * Cordis event names whose shape a one-way Remote delivery can carry: unbound
63
+ * from any Scope and returning `void`. Which ones are actually forwarded is the
64
+ * Host assembly's selection; this predicate only excludes shapes the carrier
65
+ * cannot represent.
66
+ */
67
+ export type TypertForwardableEvent = {
68
+ [Event in keyof Events]: unknown extends ThisParameterType<Events[Event]> ? ReturnType<Events[Event]> extends void ? Event : never : never;
69
+ }[keyof Events];
70
+ /** Merge-extensible forwarding selection declared once by the Host assembly. */
71
+ export interface TypertRemoteEventSelection {
72
+ }
73
+ /** Legal `$on` keys: selected events that exist in the current compilation face. */
74
+ export type TypertRemoteEvent = Extract<keyof Events, keyof TypertRemoteEventSelection>;
75
+ /**
76
+ * Resolve one direct Remote namespace from the generated flat endpoint map.
77
+ * @template Namespace - wire namespace before the endpoint slash.
78
+ */
79
+ export type TypertRemoteNamespace<Namespace extends string> = {
80
+ [Endpoint in keyof TypertRemoteMap as Endpoint extends `${Namespace}/${infer Method}` ? Method : never]: TypertRemoteMap[Endpoint];
81
+ };
82
+ /**
83
+ * Resolve one scoped Remote namespace across every generated Context kind.
84
+ * The calling Cordis Context supplies the concrete identity at runtime.
85
+ * @template Namespace - wire namespace between the Context prefix and method.
86
+ */
87
+ export type TypertRemoteScopeNamespace<Namespace extends string, ContextKey extends string = string> = {
88
+ [Endpoint in keyof TypertRemoteScopeMap as Endpoint extends `${ContextKey}:${Namespace}/${infer Method}` ? Method : never]: TypertRemoteScopeMap[Endpoint];
89
+ };
90
+ type TypertRemoteScopeNamespaceKey<ContextKey extends string, Endpoint = keyof TypertRemoteScopeMap> = Endpoint extends `${ContextKey}:${infer Namespace}/${string}` ? Namespace : never;
91
+ /** Generated scoped Remote namespaces available to one Context kind. */
92
+ export type TypertRemoteScopeApi<ContextKey extends string> = {
93
+ [Namespace in TypertRemoteScopeNamespaceKey<ContextKey>]: TypertRemoteScopeNamespace<Namespace, ContextKey>;
94
+ };
95
+ /** Merge-extensible direct namespace surface generated for Client Remote services. */
96
+ export interface TypertRemoteNamespaceMap {
97
+ }
98
+ /** Awaitable disposer returned by Cordis-owned Typert registrations. */
99
+ export type TypertDisposer = () => Promise<void>;
100
+ type StringKeyOf<Value> = Extract<keyof Value, string>;
101
+ /** Minimal runtime-schema capability carried by strict generated codecs. */
102
+ export interface TypertSchema<Output = unknown> {
103
+ /**
104
+ * Parse and validate one boundary value.
105
+ * @param value - untrusted boundary value.
106
+ * @returns the validated value.
107
+ */
108
+ parse(value: unknown): Output;
109
+ }
110
+ /** Codec attached to one invocation parameter or result. */
111
+ export type TypertCodec = {
112
+ readonly mode: 'strict';
113
+ readonly typeSymbol: string;
114
+ readonly schema: TypertSchema;
115
+ } | {
116
+ readonly mode: 'src-json';
117
+ };
118
+ /** One ordered business parameter in a Remote invocation. */
119
+ export interface InvocationParameterDescriptor {
120
+ /** Source-level parameter name. */
121
+ readonly name: string;
122
+ /** Required key in the wire `args` object. */
123
+ readonly wire: string;
124
+ /** Whether the value is JSON or requires a registered Host lookup. */
125
+ readonly source: 'json' | 'lookup';
126
+ /** Lookup key when `source` is `lookup`. */
127
+ readonly lookup?: string;
128
+ /** Boundary codec for the wire representation. */
129
+ readonly codec: TypertCodec;
130
+ /** Missing wire fields decode to `undefined` only for an explicitly declared `T | undefined`. */
131
+ readonly acceptsUndefined?: true;
132
+ }
133
+ /** Source position retained for diagnostics from generated definitions. */
134
+ export interface InvocationSourceLocation {
135
+ readonly file: string;
136
+ readonly line: number;
137
+ readonly column: number;
138
+ }
139
+ /** Carrier-independent description of one exported method invocation. */
140
+ export interface InvocationDescriptor {
141
+ /** Globally stable generated identity. */
142
+ readonly id: string;
143
+ /** Cordis service key owning the method. */
144
+ readonly service: string;
145
+ /** Wire namespace, defaulting to the service key. */
146
+ readonly namespace: string;
147
+ /** Public instance method name. */
148
+ readonly method: string;
149
+ /** Service member invoked when the exported method name is an alias. */
150
+ readonly implementation?: string;
151
+ /** Receiver selection mode. */
152
+ readonly invocation: {
153
+ readonly kind: 'direct';
154
+ } | {
155
+ readonly kind: 'context';
156
+ readonly context: string;
157
+ readonly wire: string;
158
+ readonly codec: TypertCodec;
159
+ };
160
+ /** Optional consuming-Context projection for one direct lookup parameter. */
161
+ readonly scope?: {
162
+ /** Context kind whose Client binder supplies the identity. */
163
+ readonly context: string;
164
+ /** Lookup parameter wire field replaced by the Context identity. */
165
+ readonly wire: string;
166
+ };
167
+ /** Ordered business parameters. */
168
+ readonly parameters: readonly InvocationParameterDescriptor[];
169
+ /** Transport cancellation injected after business parameters instead of entering wire args. */
170
+ readonly cancellation?: {
171
+ /** Reserved final Host method parameter. */
172
+ readonly parameter: 'signal';
173
+ };
174
+ /** Codec for the resolved method result. */
175
+ readonly result: TypertCodec;
176
+ /** Source declaration used only for diagnostics. */
177
+ readonly sourceLocation?: InvocationSourceLocation;
178
+ }
179
+ /** Generated Host contract selected explicitly by a Client assembly. */
180
+ export interface TypertRemoteContribution {
181
+ /** npm package that owns the Remote methods. */
182
+ readonly package: string;
183
+ /** Consumer-side invocation descriptors generated from that package. */
184
+ readonly descriptors: readonly InvocationDescriptor[];
185
+ }
186
+ /** Client Remote capability implemented by the Gateway and consumed by Remote assemblies. */
187
+ export interface TypertClientRemote extends TypertRemoteNamespaceMap {
188
+ /**
189
+ * Mount one generated Host-for-Client contribution in the caller's fiber.
190
+ * @param contribution - explicitly selected Remote package artifact.
191
+ * @returns disposer after namespace services and concrete methods are ready.
192
+ */
193
+ $mount(contribution: TypertRemoteContribution): Promise<TypertDisposer>;
194
+ /**
195
+ * Subscribe to one forwarded Host event; delivery is one-way, in registration
196
+ * order, and isolates a throwing listener from the rest.
197
+ * @template Event - forwarded event name selected by the Host assembly.
198
+ * @param event - forwarded Host event name, unchanged on the wire.
199
+ * @param listener - receives the Host's argument list as declared by Cordis `Events`.
200
+ * @returns disposer owned by the calling fiber.
201
+ */
202
+ $on<Event extends TypertRemoteEvent>(event: Event, listener: Events[Event]): () => void;
203
+ /**
204
+ * Hand one decoded forwarded frame to the subscription table. The carrier
205
+ * owning the Host frame sink calls this; a consumer subscribes with
206
+ * {@link TypertClientRemote.$on} and never calls it.
207
+ *
208
+ * `event` is a plain string because this is the wire boundary: the name is
209
+ * whatever the Host assembly's allowlist selected, and one nobody subscribed
210
+ * to is dropped silently.
211
+ * @param event - forwarded Host event name, exactly as the Host emitted it.
212
+ * @param args - the Host argument list, already JSON-decoded.
213
+ */
214
+ $dispatch(event: string, args: readonly unknown[]): void;
215
+ }
216
+ /**
217
+ * Resolve one validated wire identity, synchronously or asynchronously.
218
+ * @param id - validated wire identity.
219
+ * @returns the Host object, or `undefined` when unavailable.
220
+ */
221
+ export type TypertLookupResolver<Host = unknown, Wire = unknown> = (id: Wire) => Host | undefined | Promise<Host | undefined>;
222
+ /** Runtime provider for one declared Host object lookup. */
223
+ export interface TypertLookupProvider<Host = unknown, Wire = unknown> {
224
+ /** Source parameter name recognized by the SRC weak parser. */
225
+ readonly parameter: string;
226
+ /** Wire field replacing the Host object parameter. */
227
+ readonly wire: string;
228
+ /** Canonical Host type symbol used by strict generation. */
229
+ readonly hostTypeSymbol: string;
230
+ /** Canonical wire type symbol used by strict generation. */
231
+ readonly wireTypeSymbol: string;
232
+ /**
233
+ * Resolve a wire identity through the provider's default policy.
234
+ * @param id - validated wire identity.
235
+ * @returns the object, `undefined` when unavailable, or either asynchronously.
236
+ */
237
+ resolve(id: Wire): Host | undefined | Promise<Host | undefined>;
238
+ }
239
+ /** Stable wire declaration retained after a lookup provider unloads. */
240
+ export interface TypertLookupDefinition {
241
+ /** Merge-declared lookup key. */
242
+ readonly key: string;
243
+ /** Source parameter name recognized by the SRC weak parser. */
244
+ readonly parameter: string;
245
+ /** Wire field replacing the Host object parameter. */
246
+ readonly wire: string;
247
+ /** Canonical Host type symbol used by strict generation. */
248
+ readonly hostTypeSymbol: string;
249
+ /** Canonical wire type symbol used by strict generation. */
250
+ readonly wireTypeSymbol: string;
251
+ }
252
+ /** Host resolver for one scoped Remote kind. */
253
+ export interface TypertHostContextProvider<Wire = unknown> {
254
+ /** Wire field carrying the Context identity. */
255
+ readonly wire: string;
256
+ /** Canonical wire type symbol used by strict generation. */
257
+ readonly wireTypeSymbol: string;
258
+ /**
259
+ * Resolve a wire identity to its live scoped Context.
260
+ * @param id - validated wire identity.
261
+ * @returns the scoped Context, or `undefined` when unavailable.
262
+ */
263
+ resolve(id: Wire): Context | undefined | Promise<Context | undefined>;
264
+ }
265
+ /** Composition-owned resolver replacing one Host Context provider's default lookup policy. */
266
+ export type TypertHostContextResolver<Wire = unknown> = (id: Wire) => Context | undefined | Promise<Context | undefined>;
267
+ /** Client resolver for the identity carried by the calling scoped Context. */
268
+ export interface TypertClientContextBinder<Wire = unknown> {
269
+ /**
270
+ * Read the Remote identity represented by a calling Context.
271
+ * @param ctx - Context rebound by the Cordis service tracker.
272
+ * @returns the wire identity, or `undefined` when the Context has the wrong scope.
273
+ */
274
+ identity(ctx: Context): Wire | undefined;
275
+ }
276
+ /** Notification emitted after a Typert runtime registry changes. */
277
+ export interface TypertRegistryChange {
278
+ readonly kind: 'local' | 'remote' | 'lookup' | 'host-context' | 'client-context';
279
+ readonly key: string;
280
+ }
281
+ /** Listener for one Typert runtime registry. */
282
+ export type TypertRegistryListener = (change: TypertRegistryChange) => void;
283
+ /** Current-environment invocation definitions. */
284
+ export interface TypertLocalRegistry {
285
+ /**
286
+ * Look up one invocation by `<namespace>/<method>`.
287
+ * @param endpoint - canonical endpoint.
288
+ * @returns the live descriptor, or `undefined` when absent.
289
+ */
290
+ get(endpoint: string): InvocationDescriptor | undefined;
291
+ /**
292
+ * Report whether a strict definition has existed during this Typert Service lifetime.
293
+ * @param endpoint - canonical endpoint.
294
+ * @returns `true` after the endpoint has been registered at least once, even if withdrawn.
295
+ */
296
+ hasSeen(endpoint: string): boolean;
297
+ /** @returns a registration-order snapshot of local descriptors. */
298
+ list(): readonly InvocationDescriptor[];
299
+ /**
300
+ * Observe later local-definition changes.
301
+ * @param listener - synchronous contained observer.
302
+ * @returns disposer for this subscription.
303
+ */
304
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
305
+ }
306
+ /** Consumer-selected Remote contribution registry. */
307
+ export interface TypertRemoteRegistry {
308
+ /**
309
+ * Register one generated contribution for the calling Cordis fiber.
310
+ * @param contribution - generated Remote descriptors.
311
+ * @returns disposer withdrawing the exact contribution.
312
+ */
313
+ register(contribution: TypertRemoteContribution): TypertDisposer;
314
+ /**
315
+ * Look up one Remote descriptor by endpoint.
316
+ * @param endpoint - canonical endpoint.
317
+ * @returns the descriptor, or `undefined` when unmounted.
318
+ */
319
+ get(endpoint: string): InvocationDescriptor | undefined;
320
+ /** @returns a registration-order snapshot of Remote descriptors. */
321
+ list(): readonly InvocationDescriptor[];
322
+ /**
323
+ * Observe later Remote contribution changes.
324
+ * @param listener - synchronous contained observer.
325
+ * @returns disposer for this subscription.
326
+ */
327
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
328
+ }
329
+ /** Runtime registry for Host object lookup providers. */
330
+ export interface TypertLookupRegistry {
331
+ /**
332
+ * Register one provider under its merge-declared key.
333
+ * @param key - lookup key.
334
+ * @param provider - owning package's live resolver.
335
+ * @returns disposer withdrawing the exact provider.
336
+ */
337
+ register<K extends StringKeyOf<TypertLookupMap>>(key: K, provider: TypertLookupProvider<TypertLookupHost<TypertLookupMap[K]>, TypertLookupWire<TypertLookupMap[K]>>): TypertDisposer;
338
+ /**
339
+ * Replace one provider's default resolution policy while this contribution is active.
340
+ * Configuration may precede provider registration; without a live provider, `get()` remains unavailable.
341
+ * @param key - lookup key whose wire declaration remains provider-owned.
342
+ * @param resolver - composition-owned resolver used by every lookup of this key.
343
+ * @returns disposer restoring the provider's default resolver.
344
+ */
345
+ configure<K extends StringKeyOf<TypertLookupMap>>(key: K, resolver: TypertLookupResolver<TypertLookupHost<TypertLookupMap[K]>, TypertLookupWire<TypertLookupMap[K]>>): TypertDisposer;
346
+ /**
347
+ * Look up one provider by runtime key.
348
+ * @param key - descriptor lookup key.
349
+ * @returns the live provider, or `undefined` when absent.
350
+ */
351
+ get(key: string): TypertLookupProvider | undefined;
352
+ /** @returns lookup declarations observed during this Typert Service lifetime. */
353
+ definitions(): readonly TypertLookupDefinition[];
354
+ /** @returns a snapshot of registered provider keys. */
355
+ keys(): readonly string[];
356
+ /**
357
+ * Observe later lookup changes.
358
+ * @param listener - synchronous contained observer.
359
+ * @returns disposer for this subscription.
360
+ */
361
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
362
+ }
363
+ /** Runtime registry for Host Context resolvers and Client Context binders. */
364
+ export interface TypertContextRegistry {
365
+ /**
366
+ * Register a Host Context resolver.
367
+ * @param key - merge-declared Context key.
368
+ * @param provider - owning package's Host resolver.
369
+ * @returns disposer withdrawing the exact provider.
370
+ */
371
+ registerHost<K extends StringKeyOf<TypertContextMap>>(key: K, provider: TypertHostContextProvider<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
372
+ /**
373
+ * Override one Host Context key's identity policy for the calling fiber.
374
+ * Configuration may precede provider registration and restores the provider's default resolver on disposal.
375
+ * @param key - merge-declared Context key.
376
+ * @param resolver - composition-owned resolver used by every Host Context lookup of this key.
377
+ * @returns disposer restoring the provider's default resolver.
378
+ */
379
+ configureHost<K extends StringKeyOf<TypertContextMap>>(key: K, resolver: TypertHostContextResolver<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
380
+ /**
381
+ * Register a Client Context identity binder.
382
+ * @param key - merge-declared Context key.
383
+ * @param binder - Client scope identity resolver.
384
+ * @returns disposer withdrawing the exact binder.
385
+ */
386
+ registerClient<K extends StringKeyOf<TypertContextMap>>(key: K, binder: TypertClientContextBinder<TypertContextWire<TypertContextMap[K]>>): TypertDisposer;
387
+ /**
388
+ * Look up a Host Context resolver.
389
+ * @param key - descriptor Context key.
390
+ * @returns the provider, or `undefined` when absent.
391
+ */
392
+ getHost(key: string): TypertHostContextProvider | undefined;
393
+ /**
394
+ * Look up a Client Context binder.
395
+ * @param key - descriptor Context key.
396
+ * @returns the binder, or `undefined` when absent.
397
+ */
398
+ getClient(key: string): TypertClientContextBinder | undefined;
399
+ /**
400
+ * Observe later Context provider changes.
401
+ * @param listener - synchronous contained observer.
402
+ * @returns disposer for this subscription.
403
+ */
404
+ subscribe(listener: TypertRegistryListener): TypertDisposer;
405
+ }
406
+ /** Minimal Typert runtime consumed through dependency inversion. */
407
+ export interface TypertRegistryContract {
408
+ readonly local: TypertLocalRegistry;
409
+ readonly remotes: TypertRemoteRegistry;
410
+ readonly lookups: TypertLookupRegistry;
411
+ readonly contexts: TypertContextRegistry;
412
+ }
413
+ declare module '@deepseek-ai/cordis' {
414
+ interface Context {
415
+ typert: TypertRegistryContract;
416
+ }
417
+ }
418
+ export {};
419
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Compiler-independent Typert protocol shared by business packages, generated
3
+ * Remote artifacts, the Host Gateway, and Client API implementations.
4
+ * @module @deepseek-ai/dsh-typert-protocol/types
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@deepseek-ai/dsh-typert-protocol",
3
+ "description": "Compiler-independent Remote metadata and Typert provider protocols",
4
+ "version": "0.0.1-rc.3",
5
+ "publishConfig": {
6
+ "access": "restricted"
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
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./types": {
26
+ "types": "./lib/types/types.d.ts",
27
+ "default": "./lib/types/types.js"
28
+ },
29
+ "./src/*": "./src/*",
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "lib/index.js",
34
+ "lib/invariant.js",
35
+ "lib/types/**/*.js",
36
+ "lib/types/**/*.d.ts"
37
+ ],
38
+ "license": "BSD-3-Clause",
39
+ "peerDependencies": {
40
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.3",
41
+ "@deepseek-ai/cordis": "^4.0.1-rc.1"
42
+ },
43
+ "devDependencies": {
44
+ "@deepseek-ai/cordis": "^4.0.1-rc.1",
45
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.3"
46
+ }
47
+ }