refactor(typert): name the client stream handle RemoteStreamHandle everywhere
This commit is contained in:
1 parent
77f1a493aa
commit
35602063d7
32 files changed
+135
-122
No files matched your search
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write docs/api-gateway.md
|
||||
api-gateway.md: ba67476f34e124bf6cd7e2874d0a200934644b93
|
||||
api-gateway.zh.md: cdc9443b37662428a1d1ba0730cb7b558b6ca2ab
|
||||
api-gateway.md: 490a9fea0d4057d1e29ac37ad8693dedce1b6e16
|
||||
api-gateway.zh.md: 63f13140602f50c04e7aaa541cb4e0662c3c278d
|
||||
+1
-1
@@ -55,7 +55,7 @@ export class GoalService extends TypertRemoteService {
|
||||
|
||||
Remote methods may return a value synchronously or return a Promise. For cooperative cancellation, the final parameter in the Host signature must be `signal: AbortSignal` using the global type; it is recorded in the descriptor instead of entering `args`, while the generated Client method accepts an optional final `AbortSignal`.
|
||||
|
||||
`@Remote({ mode: 'stream' })` marks a method that returns `Iterable`, `AsyncIterable`, or `RemoteStream<Out, In>`: the Gateway validates and delivers each yielded item over its multiplexed `/api/remote.mux` WebSocket or an in-process carrier, and the generated Client method returns a stream handle — `RemoteStreamHandle<Out, In>`, the Client-face `RemoteStream` — that iterates the items and exposes `send`, `end`, and `dispose` for the Client-to-Host uplink of the same logical stream. The second type argument of `RemoteStream<Out, In>` declares the uplink item type; the Gateway validates each item the Client sends with the generated `In` codec before the Host method reads it through `this.ctx.invocation.uplink<In>()`. The uplink enters neither `args` nor the parameter list; the [Gateway README](../packages/api/gateway/README.md) owns the frame, half-close, cancellation, and inbox-bound contracts.
|
||||
`@Remote({ mode: 'stream' })` marks a method that returns `Iterable`, `AsyncIterable`, or `RemoteStream<Out, In>`: the Gateway validates and delivers each yielded item over its multiplexed `/api/remote.mux` WebSocket or an in-process carrier, and the generated Client method returns a `RemoteStreamHandle<Out, In>` that iterates the items and exposes `send`, `end`, and `dispose` for the Client-to-Host uplink of the same logical stream. The second type argument of `RemoteStream<Out, In>` declares the uplink item type; the Gateway validates each item the Client sends with the generated `In` codec before the Host method reads it through `this.ctx.invocation.uplink<In>()`. The uplink enters neither `args` nor the parameter list; the [Gateway README](../packages/api/gateway/README.md) owns the frame, half-close, cancellation, and inbox-bound contracts.
|
||||
|
||||
The Client uses concrete functions on ordinary objects, not a JavaScript Proxy. Direct and scoped calls appear under `ctx.remote.<namespace>` and `agentCtx.remote.<namespace>`. Each namespace is a traced Cordis child Service registered as `remote.<namespace>`; the Client assembly mounts contributions through `ctx.remote.$mount()`, and the namespace unloads after its last method is withdrawn. Dependency declarations belong to the actual caller: only a business package that reads `ctx.remote.<namespace>` or `agentCtx.remote.<namespace>` declares both `remote` and `remote.<namespace>` in its own `inject`; assemblies that only mount contributions and higher-level runtimes that do not call that namespace do not declare the namespace dependency on the business package's behalf. When an `@Remote` method has exactly one lookup parameter and a same-named `TypertContextMap` uses the same wire identity, the generated scoped signature omits that identity parameter. `@RemoteScope` generates only the scoped invocation interface.
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ export class GoalService extends TypertRemoteService {
|
||||
|
||||
Remote 方法可以同步返回或返回 Promise。若需要协作式取消,Host 签名的最后一个参数必须是全局类型的 `signal: AbortSignal`;它记录在描述符中而不是进入 `args`,Client 生成的方法则接受最后一个可选的 `AbortSignal`。
|
||||
|
||||
`@Remote({ mode: 'stream' })` 标记返回 `Iterable`、`AsyncIterable` 或 `RemoteStream<Out, In>` 的方法:Gateway 校验每个产出的项,并经其多路复用的 `/api/remote.mux` WebSocket 或进程内载体投递,Client 生成的方法返回一个流句柄——`RemoteStreamHandle<Out, In>`,即 Client 面的 `RemoteStream`——它迭代这些项,并为同一条逻辑流上从 Client 到 Host 的上行提供 `send`、`end` 与 `dispose`。`RemoteStream<Out, In>` 的第二个类型参数声明上行项类型;Gateway 在 Host 方法通过 `this.ctx.invocation.uplink<In>()` 读取之前,用生成的 `In` codec 校验 Client 发送的每一项。上行既不进入 `args` 也不进入参数列表;帧、半关闭、取消与 inbox 上限的约定由 [Gateway README](../packages/api/gateway/README.zh.md) 拥有。
|
||||
`@Remote({ mode: 'stream' })` 标记返回 `Iterable`、`AsyncIterable` 或 `RemoteStream<Out, In>` 的方法:Gateway 校验每个产出的项,并经其多路复用的 `/api/remote.mux` WebSocket 或进程内载体投递,Client 生成的方法返回一个 `RemoteStreamHandle<Out, In>`,它迭代这些项,并为同一条逻辑流上从 Client 到 Host 的上行提供 `send`、`end` 与 `dispose`。`RemoteStream<Out, In>` 的第二个类型参数声明上行项类型;Gateway 在 Host 方法通过 `this.ctx.invocation.uplink<In>()` 读取之前,用生成的 `In` codec 校验 Client 发送的每一项。上行既不进入 `args` 也不进入参数列表;帧、半关闭、取消与 inbox 上限的约定由 [Gateway README](../packages/api/gateway/README.zh.md) 拥有。
|
||||
|
||||
Client 使用普通对象上的具体函数,不使用 JavaScript Proxy。直接调用与作用域调用分别出现在 `ctx.remote.<namespace>` 和 `agentCtx.remote.<namespace>`。每个 namespace 都是注册为 `remote.<namespace>` 的可追踪 Cordis 子服务;Client assembly 通过 `ctx.remote.$mount()` 挂载贡献,最后一个方法撤回后该 namespace 随即卸载。依赖声明归实际调用方所有:只有读取 `ctx.remote.<namespace>` 或 `agentCtx.remote.<namespace>` 的业务包才在自己的 `inject` 中同时声明 `remote` 与 `remote.<namespace>`;只负责挂载 contribution 的 assembly,以及不调用该 namespace 的上层运行时,不代业务包声明 namespace 依赖。当一个 `@Remote` 方法恰好有一个 lookup 参数、且同名 `TypertContextMap` 使用相同 wire identity 时,生成的作用域签名会省略该 identity 参数。`@RemoteScope` 只生成作用域调用接口。
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write docs/subsystems/typert.md
|
||||
typert.md: 88e69f4ae264cc720efbfb8154f13a84d39160f8
|
||||
typert.zh.md: 306c1f4f46f3cb9b2816bbfcbdca5b8bc9fc2b76
|
||||
typert.md: 74ac49ce1875deef582a464d50bc581b1791aee7
|
||||
typert.zh.md: 5ff7bd82b12797ad64fbdefaae30730a4ef16ced
|
||||
@@ -136,15 +136,43 @@ The Host alias `RemoteStream<Out, In>` names both directions of one stream, and
|
||||
* items the Client may send back on the same logical stream, read through
|
||||
* `RemoteInvocation.uplink()`; it is carried only as a type-level marker. The
|
||||
* default `never` declares a method that reads none, and its descriptor
|
||||
* carries no uplink codec. On the Client face the same alias, exported by
|
||||
* `@deepseek-ai/dsh-typert-protocol/client`, is the stream handle a generated
|
||||
* method returns as `RemoteStreamHandle<Out, In>`.
|
||||
* carries no uplink codec. A generated Client stream method returns the same
|
||||
* stream as a `RemoteStreamHandle<Out, In>`.
|
||||
* @template Out - item type the Host method yields.
|
||||
* @template In - item type the Client may send; `never` when the method reads none.
|
||||
*/
|
||||
type RemoteStream<Out, In = never> = AsyncIterable<Out> & { readonly [STREAM_UPLINK]?: In }
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* One open Remote stream as the Client holds it: the downlink items as an
|
||||
* `AsyncIterable`, plus the uplink and cancellation of the same logical
|
||||
* stream. A generated Client stream method returns it. A handle stands for
|
||||
* one generation: when the carrier is lost, iteration fails with the carrier
|
||||
* error and the handle is finished.
|
||||
* @template Out - item type the Host method yields.
|
||||
* @template In - item type the Client may send; `never` when the method reads none.
|
||||
*/
|
||||
interface RemoteStreamHandle<Out, In> extends AsyncIterable<Out> {
|
||||
/**
|
||||
* Send one uplink item. Items sent before the stream has opened are queued
|
||||
* and sent once the `open` frame is on the wire.
|
||||
* @param item - item the Host validates against the method's uplink codec.
|
||||
* @throws {Error} when `end()` was called or the stream has terminated.
|
||||
*/
|
||||
send(item: In): void
|
||||
/** Half-close the uplink: the Host's `uplink()` iteration ends. Idempotent; ignored after termination. */
|
||||
end(): void
|
||||
/**
|
||||
* Cancel the logical stream: send `cancel` unless a terminal frame has
|
||||
* arrived, and end the downlink iterator quietly. Breaking out of
|
||||
* `for await` early does the same.
|
||||
*/
|
||||
dispose(): void
|
||||
}
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* One Peer's session on this Host. Opened and disposed by whoever admitted the
|
||||
|
||||
@@ -136,15 +136,43 @@ Host 别名 `RemoteStream<Out, In>` 同时命名一条流的两个方向,接
|
||||
* items the Client may send back on the same logical stream, read through
|
||||
* `RemoteInvocation.uplink()`; it is carried only as a type-level marker. The
|
||||
* default `never` declares a method that reads none, and its descriptor
|
||||
* carries no uplink codec. On the Client face the same alias, exported by
|
||||
* `@deepseek-ai/dsh-typert-protocol/client`, is the stream handle a generated
|
||||
* method returns as `RemoteStreamHandle<Out, In>`.
|
||||
* carries no uplink codec. A generated Client stream method returns the same
|
||||
* stream as a `RemoteStreamHandle<Out, In>`.
|
||||
* @template Out - item type the Host method yields.
|
||||
* @template In - item type the Client may send; `never` when the method reads none.
|
||||
*/
|
||||
type RemoteStream<Out, In = never> = AsyncIterable<Out> & { readonly [STREAM_UPLINK]?: In }
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* One open Remote stream as the Client holds it: the downlink items as an
|
||||
* `AsyncIterable`, plus the uplink and cancellation of the same logical
|
||||
* stream. A generated Client stream method returns it. A handle stands for
|
||||
* one generation: when the carrier is lost, iteration fails with the carrier
|
||||
* error and the handle is finished.
|
||||
* @template Out - item type the Host method yields.
|
||||
* @template In - item type the Client may send; `never` when the method reads none.
|
||||
*/
|
||||
interface RemoteStreamHandle<Out, In> extends AsyncIterable<Out> {
|
||||
/**
|
||||
* Send one uplink item. Items sent before the stream has opened are queued
|
||||
* and sent once the `open` frame is on the wire.
|
||||
* @param item - item the Host validates against the method's uplink codec.
|
||||
* @throws {Error} when `end()` was called or the stream has terminated.
|
||||
*/
|
||||
send(item: In): void
|
||||
/** Half-close the uplink: the Host's `uplink()` iteration ends. Idempotent; ignored after termination. */
|
||||
end(): void
|
||||
/**
|
||||
* Cancel the logical stream: send `cancel` unless a terminal frame has
|
||||
* arrived, and end the downlink iterator quietly. Breaking out of
|
||||
* `for await` early does the same.
|
||||
*/
|
||||
dispose(): void
|
||||
}
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* One Peer's session on this Host. Opened and disposed by whoever admitted the
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/api/gateway/README.md
|
||||
README.md: 9cf250a0578789557c02b88e2ec0c34620196644
|
||||
README.zh.md: 757b7bb45a6828e86fba31c06088020302344512
|
||||
README.md: 6275cc09b2a27a6fb635ea506cc52c54e459e920
|
||||
README.zh.md: b9078fff9aeed3a2416b435c1bb53cba13ed353f
|
||||
@@ -45,7 +45,7 @@ The browser carrier accepts the shell-owned stream origin described by [Connecti
|
||||
|
||||
`ctx.remote.$mount()` validates and registers a generated Host-for-Client contribution, then installs concrete direct and scoped methods for the calling Cordis fiber. Each namespace is a traced `remote.<namespace>` child Service and unloads after its last method is withdrawn. Duplicate endpoints, namespace collisions, and Client-supplied fields without strict generated codecs fail before methods become callable.
|
||||
|
||||
Each unary call checks positional arity, constructs the descriptor's exact named `args`, and sends the typed values through `ctx.connection.rpc.call('/api', endpoint, ...)` without executing Client-side schemas; the Host validates the received wire fields before business invocation. A generated stream method returns a `RemoteStreamHandle<Out, In>` — the `RemoteStream<Out, In>` alias of `@deepseek-ai/dsh-typert-protocol/client` — and opens one logical stream when it is called, through an in-process Connection carrier when available, otherwise through the shared Gateway WebSocket. The handle iterates the downlink once. `send(item)` queues an uplink item, sent after the `open` frame; `end()` half-closes the uplink; `dispose()` sends `cancel` unless a terminal frame has arrived and ends the iteration quietly. Breaking out of the iteration early disposes the handle; after the downlink terminates `send` throws and `end` is ignored. Generated cancellation-aware methods accept a final optional `AbortSignal`; the Client combines it with the contribution mount lifetime before invoking the carrier. Successful unary results and stream items pass through without Client-side type parsing. Withdrawing a contribution removes its descriptors and methods together, aborts in-flight calls and streams, and makes retained method handles reject.
|
||||
Each unary call checks positional arity, constructs the descriptor's exact named `args`, and sends the typed values through `ctx.connection.rpc.call('/api', endpoint, ...)` without executing Client-side schemas; the Host validates the received wire fields before business invocation. A generated stream method returns a `RemoteStreamHandle<Out, In>` from `dsh-typert-protocol` and opens one logical stream when it is called, through an in-process Connection carrier when available, otherwise through the shared Gateway WebSocket. The handle iterates the downlink once. `send(item)` queues an uplink item, sent after the `open` frame; `end()` half-closes the uplink; `dispose()` sends `cancel` unless a terminal frame has arrived and ends the iteration quietly. Breaking out of the iteration early disposes the handle; after the downlink terminates `send` throws and `end` is ignored. Generated cancellation-aware methods accept a final optional `AbortSignal`; the Client combines it with the contribution mount lifetime before invoking the carrier. Successful unary results and stream items pass through without Client-side type parsing. Withdrawing a contribution removes its descriptors and methods together, aborts in-flight calls and streams, and makes retained method handles reject.
|
||||
|
||||
Every unary call resolves to `RemoteResult<T>` — `{ ok: true, value }` or `{ ok: false, error }` — and never rejects for a carrier problem: this face folds an offline carrier into the error branch and answers `gateway/cancelled` when the caller's signal aborts, so no consumer wraps a call to recover one. Only an assembly fault still rejects: wrong arity, an unmounted method, a withdrawn contribution, a missing Context adapter. `error` is a live `RemoteError` instance, so `throw result.error` keeps throw semantics, and `isRemoteFailure(value)` is the one predicate a consumer needs — a caught value it accepts carries a Host code, and anything it rejects is a local fault the caller should let crash. `carrierFailure(endpoint, error)` and `cancelledFailure(endpoint, cause)` build those two folded results, so a test stand-in for this face folds identically.
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ Host 组合可通过 `registerRemoteEvents()` 注册唯一的应用事件 source
|
||||
|
||||
`ctx.remote.$mount()` 会校验并注册生成的 Host-for-Client 贡献项,然后为发起调用的 Cordis fiber 安装具体的直接方法和作用域方法。每个 namespace 都是可追踪的 `remote.<namespace>` 子 Service,并在最后一个方法撤回后卸载。重复端点、命名空间冲突,以及缺少生成的严格 codec 的 Client 供值字段,都会在方法可调用前报错。
|
||||
|
||||
每次一元调用都会检查位置参数数量,构造与描述符完全匹配的具名 `args`,再把带类型的值原样交给 `ctx.connection.rpc.call('/api', endpoint, ...)`,而不执行 Client 侧 schema;Host 会在业务调用前校验收到的 wire 字段。生成的流方法返回 `RemoteStreamHandle<Out, In>`——即 `@deepseek-ai/dsh-typert-protocol/client` 的 `RemoteStream<Out, In>` 别名——并在被调用时就打开一条逻辑流,进程内 Connection 载体可用时通过它打开,否则通过共享的 Gateway WebSocket 打开。句柄只迭代下行一次。`send(item)` 把一个上行项入队,在 `open` 帧之后发出;`end()` 半关闭上行;`dispose()` 在未收到终止帧时发送 `cancel`,并让迭代安静结束。提前跳出迭代等价于 dispose 句柄;下行终止后 `send` 抛错,`end` 被忽略。生成的支持取消的方法接受最后一个可选 `AbortSignal`;Client 会在调用载体前将它与贡献项的挂载生命周期合并。成功的一元结果与流项不经 Client 侧类型解析直接传递。撤回贡献项会同时移除其描述符和方法、中止正在进行的调用与流,并使外部仍持有的方法句柄在调用时返回拒绝。
|
||||
每次一元调用都会检查位置参数数量,构造与描述符完全匹配的具名 `args`,再把带类型的值原样交给 `ctx.connection.rpc.call('/api', endpoint, ...)`,而不执行 Client 侧 schema;Host 会在业务调用前校验收到的 wire 字段。生成的流方法返回 `dsh-typert-protocol` 的 `RemoteStreamHandle<Out, In>`,并在被调用时就打开一条逻辑流,进程内 Connection 载体可用时通过它打开,否则通过共享的 Gateway WebSocket 打开。句柄只迭代下行一次。`send(item)` 把一个上行项入队,在 `open` 帧之后发出;`end()` 半关闭上行;`dispose()` 在未收到终止帧时发送 `cancel`,并让迭代安静结束。提前跳出迭代等价于 dispose 句柄;下行终止后 `send` 抛错,`end` 被忽略。生成的支持取消的方法接受最后一个可选 `AbortSignal`;Client 会在调用载体前将它与贡献项的挂载生命周期合并。成功的一元结果与流项不经 Client 侧类型解析直接传递。撤回贡献项会同时移除其描述符和方法、中止正在进行的调用与流,并使外部仍持有的方法句柄在调用时返回拒绝。
|
||||
|
||||
每次一元调用都解析为 `RemoteResult<T>`——`{ ok: true, value }` 或 `{ ok: false, error }`——且绝不因载体问题 reject:本面把断线载体折入错误分支,调用方 signal 中止时答以 `gateway/cancelled`,因此没有消费方需要包一层来兜载体失败。只有装配故障仍会 reject:参数个数不符、方法未挂载、贡献已撤下、缺少 Context 适配器。`error` 是活的 `RemoteError` 实例,所以 `throw result.error` 保持 throw 语义;而 `isRemoteFailure(value)` 是消费方唯一需要的谓词——它认下的捕获值带着 Host 码,它拒绝的一律是本地故障,调用方应当让其崩掉。`carrierFailure(endpoint, error)` 与 `cancelledFailure(endpoint, cause)` 构造这两种折叠结果,测试里的替代实现据此采用相同的折叠方式。
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
import { Service } from '@deepseek-ai/cordis'
|
||||
import { Deque } from '@deepseek-ai/dsh-deque'
|
||||
import { RemoteError, remoteErrorOf } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'
|
||||
export type { TypertGatewayFaultDetails } from '../remote-error-codes.ts'
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import type {
|
||||
@@ -19,6 +18,7 @@ import type {
|
||||
TypertClientRemote,
|
||||
RemoteFailure,
|
||||
RemoteResult,
|
||||
RemoteStreamHandle,
|
||||
TypertCodec,
|
||||
TypertDisposer,
|
||||
TypertRemoteContribution,
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import type {
|
||||
InvocationDescriptor,
|
||||
RemoteResult,
|
||||
RemoteStreamHandle,
|
||||
TypertContextMap,
|
||||
TypertContextWire,
|
||||
TypertContext,
|
||||
@@ -21,7 +22,6 @@ import type {
|
||||
TypertRemoteScopeApi,
|
||||
TypertRemoteNamespace,
|
||||
} from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'
|
||||
import TypertRegistry from '@deepseek-ai/dsh-typert-registry'
|
||||
import type { ClientRemote } from '../src/client/index.ts'
|
||||
import { apply, inject, RemoteStream } from '../src/client/index.ts'
|
||||
|
||||
@@ -5,11 +5,10 @@ import {
|
||||
type RemoteStreamOptions,
|
||||
} from '@deepseek-ai/dsh-api-gateway/client'
|
||||
import { RemoteError } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'
|
||||
import { streamHandle } from '@deepseek-ai/dsh-remote-mock'
|
||||
import { LlmAttemptId } from '@deepseek-ai/dsh-llm'
|
||||
import { SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session/types'
|
||||
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { RemoteResult, RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import {
|
||||
createSessionControlStream,
|
||||
SessionEventStream,
|
||||
|
||||
@@ -22,8 +22,7 @@ import type {
|
||||
WorkspaceId,
|
||||
WorkspaceView,
|
||||
} from '../src/types.ts'
|
||||
import { RemoteError, type RemoteFailure, type RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'
|
||||
import { RemoteError, type RemoteFailure, type RemoteResult, type RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import { streamHandle } from '@deepseek-ai/dsh-remote-mock'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
* opened `changes` generation, and a supervisor that runs one generation and
|
||||
* classifies its end the way the real one does.
|
||||
*/
|
||||
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { RemoteResult, RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import { RemoteError } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'
|
||||
import { streamHandle } from '@deepseek-ai/dsh-remote-mock'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import type { WorkspaceFileWatchFrame, WorkspaceFileStat } from '../src/types.ts'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Stream scripts and the pushable, abort-aware stream a script drives. */
|
||||
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { StreamRecord } from './log.ts'
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Stream scripts, live stream control, cancellation, and the built-in `$events` opening. */
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import { RemoteMock, frames, openStream, streamHandle, streamMethod } from '../src/index.ts'
|
||||
|
||||
const idle = (): AbortSignal => new AbortController().signal
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/typert/generator/README.md
|
||||
README.md: ad78a9108fe7b1f8178ff9866649633ed5072c60
|
||||
README.zh.md: c88b8bdd67e8c271817ff668ae4b62f7ea8b541d
|
||||
README.md: aa7fd3d6e068ea6532d55de04970ab3e28b74285
|
||||
README.zh.md: e911feac821deda1d0876c26c575dcff5cd2a741
|
||||
@@ -79,7 +79,7 @@ The generator is built on one separation: extraction and emission are decoupled
|
||||
|
||||
### Analysis and faces
|
||||
|
||||
Host and Client are independent TypeScript programs. Direct project references establish compiler-face membership, while `dsh.client` package subpaths establish runtime-face contribution; `package.json#exports` marks every cross-package public boundary, and imports or re-exports are the only cross-face edges. A relative import that resolves inside the referencing package is followed through that module's re-exports until a package specifier appears, so package-local forwarding modules keep their original declaration references; a relative import that resolves into another package fails. `check` mode fails on syntax or semantic diagnostics, missing public annotations, private cross-package references, and reachable declaration merges the model cannot retain losslessly; `write` mode inserts checker-derived annotations and returns a clean check-mode model. Types owned by NPM dependencies remain `external` references instead of being expanded. A stream method's return type may be `Iterable<Out>`, `AsyncIterable<Out>`, or the protocol's `RemoteStream<Out, In>`, recognized by symbol and declaring package like the standard-library wrappers; a second type argument other than `never` yields the descriptor's uplink codec, and the generated Client signature returns `RemoteStreamHandle<Out, In>` from the protocol's Client entry.
|
||||
Host and Client are independent TypeScript programs. Direct project references establish compiler-face membership, while `dsh.client` package subpaths establish runtime-face contribution; `package.json#exports` marks every cross-package public boundary, and imports or re-exports are the only cross-face edges. A relative import that resolves inside the referencing package is followed through that module's re-exports until a package specifier appears, so package-local forwarding modules keep their original declaration references; a relative import that resolves into another package fails. `check` mode fails on syntax or semantic diagnostics, missing public annotations, private cross-package references, and reachable declaration merges the model cannot retain losslessly; `write` mode inserts checker-derived annotations and returns a clean check-mode model. Types owned by NPM dependencies remain `external` references instead of being expanded. A stream method's return type may be `Iterable<Out>`, `AsyncIterable<Out>`, or the protocol's `RemoteStream<Out, In>`, recognized by symbol and declaring package like the standard-library wrappers; a second type argument other than `never` yields the descriptor's uplink codec, and the generated Client signature returns `RemoteStreamHandle<Out, In>`.
|
||||
|
||||
### Emission and publication contract
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ files:
|
||||
|
||||
### 分析与 face
|
||||
|
||||
Host 与 Client 是两个独立的 TypeScript 程序。直接项目引用确定编译器 face 的成员归属,`dsh.client` 包子路径则确定运行时 face 的贡献;`package.json#exports` 划定所有跨包公开边界,跨 face 的边只能来自导入或重新导出。解析到本包内部模块的相对导入会沿该模块的重新导出继续追踪,直到出现包说明符,因此包内转发模块保留原始声明引用;解析到其他包的相对导入会失败。`check` 模式遇到语法或语义诊断、缺失的公开类型标注、跨包私有引用,以及模型无法无损保留的可达声明合并时都会失败;`write` 模式插入类型检查器推导出的标注,并返回无诊断的 check 模式模型。NPM 依赖拥有的类型继续以 `external` 引用表示,不会被展开。流方法的返回类型可以是 `Iterable<Out>`、`AsyncIterable<Out>` 或协议包的 `RemoteStream<Out, In>`,后者与标准库包装器一样按符号名与声明所在包识别;第二个类型参数不为 `never` 时产出描述符的上行编解码器,生成的 Client 签名则返回来自协议包 Client 入口的 `RemoteStreamHandle<Out, In>`。
|
||||
Host 与 Client 是两个独立的 TypeScript 程序。直接项目引用确定编译器 face 的成员归属,`dsh.client` 包子路径则确定运行时 face 的贡献;`package.json#exports` 划定所有跨包公开边界,跨 face 的边只能来自导入或重新导出。解析到本包内部模块的相对导入会沿该模块的重新导出继续追踪,直到出现包说明符,因此包内转发模块保留原始声明引用;解析到其他包的相对导入会失败。`check` 模式遇到语法或语义诊断、缺失的公开类型标注、跨包私有引用,以及模型无法无损保留的可达声明合并时都会失败;`write` 模式插入类型检查器推导出的标注,并返回无诊断的 check 模式模型。NPM 依赖拥有的类型继续以 `external` 引用表示,不会被展开。流方法的返回类型可以是 `Iterable<Out>`、`AsyncIterable<Out>` 或协议包的 `RemoteStream<Out, In>`,后者与标准库包装器一样按符号名与声明所在包识别;第二个类型参数不为 `never` 时产出描述符的上行编解码器,生成的 Client 签名则返回 `RemoteStreamHandle<Out, In>`。
|
||||
|
||||
### 生成与发布约定
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@ import type {
|
||||
} from './model.ts'
|
||||
import { TypeGraphRenderer } from './renderer.ts'
|
||||
|
||||
/** Protocol entry that exports the handle a generated Client stream method returns. */
|
||||
const REMOTE_CLIENT_PROTOCOL = '@deepseek-ai/dsh-typert-protocol/client'
|
||||
|
||||
/** Failure to project a modeled construct into an emitted artifact. */
|
||||
export class TypertEmitError extends Error {
|
||||
override name = 'TypertEmitError'
|
||||
@@ -352,18 +349,15 @@ export class FaceModelEmitter {
|
||||
})
|
||||
grouped.set(imported.specifier, values)
|
||||
}
|
||||
// A stream method's Client signature names the handle from the protocol's
|
||||
// Client entry; the Host entry's `RemoteStream` alias would shadow a
|
||||
// same-named import inside the augmentation below.
|
||||
// A stream method's Client signature returns the handle; `RemoteStream` names
|
||||
// what the Host method returns.
|
||||
const lines = [
|
||||
'/* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */',
|
||||
'import type {',
|
||||
' RemoteResult,',
|
||||
...packageModel.invocations.some(invocation => invocation.mode === 'stream') ? [' RemoteStreamHandle,'] : [],
|
||||
' TypertRemoteContribution,',
|
||||
'} from \'@deepseek-ai/dsh-typert-protocol\'',
|
||||
...packageModel.invocations.some(invocation => invocation.mode === 'stream')
|
||||
? [`import type { RemoteStreamHandle } from ${quote(REMOTE_CLIENT_PROTOCOL)}`]
|
||||
: [],
|
||||
]
|
||||
const sourceMap = new GenMapping({ file: 'typert.remote-client.d.ts' })
|
||||
for (const [specifier, values] of [...grouped].sort(([left], [right]) => left.localeCompare(right))) {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
"ignoreDeprecations": "6.0",
|
||||
"paths": {
|
||||
"@deepseek-ai/dsh-typert-protocol": ["./typert-protocol.d.ts"],
|
||||
"@deepseek-ai/dsh-typert-protocol/client": ["./typert-protocol.d.ts"],
|
||||
"@fixture/domain": ["./packages/domain/src/index.ts"],
|
||||
"@fixture/domain/*": ["./packages/domain/src/*"],
|
||||
"@fixture/remote": ["./packages/remote/src/index.ts"],
|
||||
|
||||
+6
-18
@@ -38,6 +38,12 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
|
||||
|
||||
export type RemoteStream<Out, In = never> = AsyncIterable<Out> & { readonly uplinkItem?: In }
|
||||
|
||||
export interface RemoteStreamHandle<Out, In> extends AsyncIterable<Out> {
|
||||
send(item: In): void
|
||||
end(): void
|
||||
dispose(): void
|
||||
}
|
||||
|
||||
export abstract class TypertRemoteService {
|
||||
readonly typertRemote: {
|
||||
readonly service: TypertRemoteService
|
||||
@@ -74,21 +80,3 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
|
||||
context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Result>,
|
||||
) => void
|
||||
}
|
||||
|
||||
declare module '@deepseek-ai/dsh-typert-protocol/client' {
|
||||
export interface RemoteStreamHandle<Out, In> extends AsyncIterable<Out> {
|
||||
send(item: In): void
|
||||
end(): void
|
||||
dispose(): void
|
||||
}
|
||||
|
||||
export type RemoteStream<Out, In = never> = RemoteStreamHandle<Out, In>
|
||||
|
||||
export type {
|
||||
RemoteResult,
|
||||
TypertRemoteContribution,
|
||||
TypertRemoteMap,
|
||||
TypertRemoteNamespaceMap,
|
||||
TypertRemoteScopeMap,
|
||||
} from '@deepseek-ai/dsh-typert-protocol'
|
||||
}
|
||||
@@ -272,7 +272,7 @@ export type {`,
|
||||
|
||||
const [artifact] = new WorkspaceTypertGenerator(root).generate()
|
||||
expect(artifact?.remote?.dts).toContain(
|
||||
"import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'",
|
||||
" RemoteStreamHandle,\n TypertRemoteContribution,\n} from '@deepseek-ai/dsh-typert-protocol'",
|
||||
)
|
||||
expect(artifact?.remote?.dts).toContain("declare module '@deepseek-ai/dsh-typert-protocol' {")
|
||||
expect(artifact?.remote?.dts).toContain(
|
||||
@@ -755,12 +755,12 @@ function assertRemoteConsumerTypechecks(
|
||||
import remote from '@fixture/remote/remote'
|
||||
import type {
|
||||
RemoteResult,
|
||||
RemoteStreamHandle,
|
||||
TypertRemoteContribution,
|
||||
TypertRemoteScopeMap,
|
||||
TypertRemoteMap,
|
||||
TypertRemoteNamespaceMap,
|
||||
} from '@deepseek-ai/dsh-typert-protocol'
|
||||
import type { RemoteStreamHandle } from '@deepseek-ai/dsh-typert-protocol/client'
|
||||
import type { CreateGoalResult, RenameGoalResult } from '@fixture/remote/types'
|
||||
|
||||
const contribution: TypertRemoteContribution = remote
|
||||
@@ -792,7 +792,6 @@ void navigated
|
||||
skipLibCheck: false,
|
||||
paths: {
|
||||
'@deepseek-ai/dsh-typert-protocol': ['./typert-protocol.d.ts'],
|
||||
'@deepseek-ai/dsh-typert-protocol/client': ['./typert-protocol.d.ts'],
|
||||
'@fixture/domain/types': ['./packages/domain/src/types.ts'],
|
||||
'@fixture/remote/types': ['./packages/remote/src/types.ts'],
|
||||
'@fixture/remote/remote': ['./packages/remote/lib/typert.remote-client.d.ts'],
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/typert/protocol/README.md
|
||||
README.md: f69c02a0a0e4b416c5749844f29a11ac0f5f9078
|
||||
README.zh.md: 588812fbd0afb8d420c67a838935edb5817d4137
|
||||
README.md: f3a758cc9f65ccfff7d5f15af801702359674fa3
|
||||
README.zh.md: 4630124ff623ca8223dcae326403c5504db52483
|
||||
@@ -44,7 +44,7 @@ export class GoalService extends TypertRemoteService {
|
||||
|
||||
Generation turns the method into a wire endpoint under the service's namespace; Clients call it as a typed method through `ctx.remote` (see the [API Gateway reference](../../../docs/api-gateway.md)). A method opts into cooperative cancellation by declaring `signal: AbortSignal` as its final parameter — the signal is injected, never a JSON parameter or lookup field.
|
||||
|
||||
A stream method (`@Remote({ mode: 'stream' })`) returns `Iterable`, `AsyncIterable`, or `RemoteStream<Out, In>`. `In` declares the items the Client may send back on the same logical stream; the method reads them through `this.ctx.invocation.uplink<In>()`, and the descriptor carries their codec. `RemoteInvocation` also names the receiving `service`, the calling `peer` (a `PeerScope` the connection layer admitted), and the carrier `signal`; `ctx.invocation` is `undefined` on a Context no Remote call derived. On the Client face, `@deepseek-ai/dsh-typert-protocol/client` exports `RemoteStreamHandle` and resolves `RemoteStream<Out, In>` to it: the handle a generated stream method returns, with `send`, `end`, and `dispose` beside the downlink iteration.
|
||||
A stream method (`@Remote({ mode: 'stream' })`) returns `Iterable`, `AsyncIterable`, or `RemoteStream<Out, In>`. `In` declares the items the Client may send back on the same logical stream; the method reads them through `this.ctx.invocation.uplink<In>()`, and the descriptor carries their codec. `RemoteInvocation` also names the receiving `service`, the calling `peer` (a `PeerScope` the connection layer admitted), and the carrier `signal`; `ctx.invocation` is `undefined` on a Context no Remote call derived. A generated Client stream method returns `RemoteStreamHandle<Out, In>`: the handle with `send`, `end`, and `dispose` beside the downlink iteration.
|
||||
|
||||
### Associating Host objects and Contexts with wire identities
|
||||
|
||||
@@ -103,8 +103,7 @@ Every namespace, method, lookup, and Context segment must satisfy `isTypertRemot
|
||||
|---|---|
|
||||
| [`src/index.ts`](src/index.ts) | Decorators, Gateway bindings, `remoteMethods`, segment validation |
|
||||
| [`src/remote-error.ts`](src/remote-error.ts) | `RemoteError` and the structural `remoteErrorOf` recognizer |
|
||||
| [`src/types.ts`](src/types.ts) | Protocol maps, `RemoteErrorDetailsMap`, `RemoteResult`, `RemoteStream`, `PeerScope`, `RemoteInvocation`, `InvocationDescriptor`, codecs, provider contracts, registry interfaces, `TypertClientRemote` |
|
||||
| [`src/client/index.ts`](src/client/index.ts) | Client face: `RemoteStreamHandle`, the Client `RemoteStream` alias, and every Host export |
|
||||
| [`src/types.ts`](src/types.ts) | Protocol maps, `RemoteErrorDetailsMap`, `RemoteResult`, `RemoteStream`, `RemoteStreamHandle`, `PeerScope`, `RemoteInvocation`, `InvocationDescriptor`, codecs, provider contracts, registry interfaces, `TypertClientRemote` |
|
||||
| — | No runtime invariant companion is published; decorators retain private immutable declarations and bindings are frozen values with no independent event stream to cross-check. |
|
||||
|
||||
</details>
|
||||
|
||||
@@ -44,7 +44,7 @@ export class GoalService extends TypertRemoteService {
|
||||
|
||||
生成会把方法变为服务命名空间下的 wire 端点;Client 通过 `ctx.remote` 以类型化方法调用它(见 [API Gateway 参考](../../../docs/api-gateway.zh.md))。方法把 `signal: AbortSignal` 声明为最后一个参数即可选择协作式取消——该信号是注入的,绝不会成为 JSON 参数或查找字段。
|
||||
|
||||
流方法(`@Remote({ mode: 'stream' })`)返回 `Iterable`、`AsyncIterable` 或 `RemoteStream<Out, In>`。`In` 声明 Client 可以在同一条逻辑流上回送的项;方法通过 `this.ctx.invocation.uplink<In>()` 读取它们,描述符携带其 codec。`RemoteInvocation` 还给出接收服务 `service`、发起调用的 `peer`(连接层接纳的一个 `PeerScope`)与载体 `signal`;非 Remote 调用派生的 Context 上 `ctx.invocation` 为 `undefined`。在 Client 面,`@deepseek-ai/dsh-typert-protocol/client` 导出 `RemoteStreamHandle` 并把 `RemoteStream<Out, In>` 解析为它:生成的流方法返回的句柄,在下行迭代之外提供 `send`、`end` 与 `dispose`。
|
||||
流方法(`@Remote({ mode: 'stream' })`)返回 `Iterable`、`AsyncIterable` 或 `RemoteStream<Out, In>`。`In` 声明 Client 可以在同一条逻辑流上回送的项;方法通过 `this.ctx.invocation.uplink<In>()` 读取它们,描述符携带其 codec。`RemoteInvocation` 还给出接收服务 `service`、发起调用的 `peer`(连接层接纳的一个 `PeerScope`)与载体 `signal`;非 Remote 调用派生的 Context 上 `ctx.invocation` 为 `undefined`。生成的 Client 流方法返回 `RemoteStreamHandle<Out, In>`:在下行迭代之外提供 `send`、`end` 与 `dispose` 的句柄。
|
||||
|
||||
### 把 Host 对象与 Context 关联到 wire identity
|
||||
|
||||
@@ -103,8 +103,7 @@ Host 装配以转发给消费方的 Cordis 事件扩展 `TypertRemoteEventSelect
|
||||
|---|---|
|
||||
| [`src/index.ts`](src/index.ts) | 装饰器、Gateway 绑定、`remoteMethods`、段校验 |
|
||||
| [`src/remote-error.ts`](src/remote-error.ts) | `RemoteError` 与结构式识别函数 `remoteErrorOf` |
|
||||
| [`src/types.ts`](src/types.ts) | 协议映射、`RemoteErrorDetailsMap`、`RemoteResult`、`RemoteStream`、`PeerScope`、`RemoteInvocation`、`InvocationDescriptor`、编解码器、提供方约定、注册表接口、`TypertClientRemote` |
|
||||
| [`src/client/index.ts`](src/client/index.ts) | Client 面:`RemoteStreamHandle`、Client 侧的 `RemoteStream` 别名,以及全部 Host 导出 |
|
||||
| [`src/types.ts`](src/types.ts) | 协议映射、`RemoteErrorDetailsMap`、`RemoteResult`、`RemoteStream`、`RemoteStreamHandle`、`PeerScope`、`RemoteInvocation`、`InvocationDescriptor`、编解码器、提供方约定、注册表接口、`TypertClientRemote` |
|
||||
| — | 不发布运行时不变量伴生入口;decorator 只保留私有不可变声明,binding 也是冻结值,没有可供交叉核对的独立事件流。 |
|
||||
|
||||
</details>
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
"types": "./lib/types/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./client": {
|
||||
"types": "./lib/types/client/index.d.ts",
|
||||
"default": "./lib/types/client/index.js"
|
||||
},
|
||||
"./types": {
|
||||
"types": "./lib/types/types.d.ts",
|
||||
"default": "./lib/types/types.js"
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* Client face of the Typert protocol: every Host export, with `RemoteStream`
|
||||
* resolving to the handle a generated Client method returns. Generated
|
||||
* Host-for-Client contracts import `RemoteStreamHandle` from this entry for
|
||||
* their stream signatures, so Client code that names a stream as
|
||||
* `RemoteStream<Out, In>` from this entry and the generated method agree,
|
||||
* while the Host alias stays an `AsyncIterable<Out>`.
|
||||
* @module @deepseek-ai/dsh-typert-protocol/client
|
||||
*/
|
||||
|
||||
/**
|
||||
* One open Remote stream as the Client holds it: the downlink items as an
|
||||
* `AsyncIterable`, plus the uplink and cancellation of the same logical
|
||||
* stream. A handle stands for one generation: when the carrier is lost,
|
||||
* iteration fails with the carrier error and the handle is finished.
|
||||
* @template Out - item type the Host method yields.
|
||||
* @template In - item type the Client may send; `never` when the method reads none.
|
||||
*/
|
||||
export interface RemoteStreamHandle<Out, In> extends AsyncIterable<Out> {
|
||||
/**
|
||||
* Send one uplink item. Items sent before the stream has opened are queued
|
||||
* and sent once the `open` frame is on the wire.
|
||||
* @param item - item the Host validates against the method's uplink codec.
|
||||
* @throws {Error} when `end()` was called or the stream has terminated.
|
||||
*/
|
||||
send(item: In): void
|
||||
/** Half-close the uplink: the Host's `uplink()` iteration ends. Idempotent; ignored after termination. */
|
||||
end(): void
|
||||
/**
|
||||
* Cancel the logical stream: send `cancel` unless a terminal frame has
|
||||
* arrived, and end the downlink iterator quietly. Breaking out of
|
||||
* `for await` early does the same.
|
||||
*/
|
||||
dispose(): void
|
||||
}
|
||||
|
||||
/**
|
||||
* `RemoteStream<Out, In>` on the Client face: the handle a generated Remote
|
||||
* method returns.
|
||||
* @template Out - item type the Host method yields.
|
||||
* @template In - item type the Client may send; `never` when the method reads none.
|
||||
*/
|
||||
export type RemoteStream<Out, In = never> = RemoteStreamHandle<Out, In>
|
||||
|
||||
export * from '../index.ts'
|
||||
@@ -35,6 +35,7 @@ export type {
|
||||
RemoteInvocation,
|
||||
RemoteResult,
|
||||
RemoteStream,
|
||||
RemoteStreamHandle,
|
||||
TypertClientEventListener,
|
||||
TypertClientRemote,
|
||||
TypertClientContextAdapter,
|
||||
|
||||
@@ -85,14 +85,40 @@ declare const STREAM_UPLINK: unique symbol
|
||||
* items the Client may send back on the same logical stream, read through
|
||||
* `RemoteInvocation.uplink()`; it is carried only as a type-level marker. The
|
||||
* default `never` declares a method that reads none, and its descriptor
|
||||
* carries no uplink codec. On the Client face the same alias, exported by
|
||||
* `@deepseek-ai/dsh-typert-protocol/client`, is the stream handle a generated
|
||||
* method returns as `RemoteStreamHandle<Out, In>`.
|
||||
* carries no uplink codec. A generated Client stream method returns the same
|
||||
* stream as a `RemoteStreamHandle<Out, In>`.
|
||||
* @template Out - item type the Host method yields.
|
||||
* @template In - item type the Client may send; `never` when the method reads none.
|
||||
*/
|
||||
export type RemoteStream<Out, In = never> = AsyncIterable<Out> & { readonly [STREAM_UPLINK]?: In }
|
||||
|
||||
/**
|
||||
* One open Remote stream as the Client holds it: the downlink items as an
|
||||
* `AsyncIterable`, plus the uplink and cancellation of the same logical
|
||||
* stream. A generated Client stream method returns it. A handle stands for
|
||||
* one generation: when the carrier is lost, iteration fails with the carrier
|
||||
* error and the handle is finished.
|
||||
* @template Out - item type the Host method yields.
|
||||
* @template In - item type the Client may send; `never` when the method reads none.
|
||||
*/
|
||||
export interface RemoteStreamHandle<Out, In> extends AsyncIterable<Out> {
|
||||
/**
|
||||
* Send one uplink item. Items sent before the stream has opened are queued
|
||||
* and sent once the `open` frame is on the wire.
|
||||
* @param item - item the Host validates against the method's uplink codec.
|
||||
* @throws {Error} when `end()` was called or the stream has terminated.
|
||||
*/
|
||||
send(item: In): void
|
||||
/** Half-close the uplink: the Host's `uplink()` iteration ends. Idempotent; ignored after termination. */
|
||||
end(): void
|
||||
/**
|
||||
* Cancel the logical stream: send `cancel` unless a terminal frame has
|
||||
* arrived, and end the downlink iterator quietly. Breaking out of
|
||||
* `for await` early does the same.
|
||||
*/
|
||||
dispose(): void
|
||||
}
|
||||
|
||||
/** Merge-extensible scoped Remote method signatures generated for consumers. */
|
||||
export interface TypertRemoteScopeMap {}
|
||||
|
||||
|
||||
@@ -1921,6 +1921,11 @@
|
||||
"symbol": "RemoteStream",
|
||||
"source": "packages/typert/protocol/src/types.ts"
|
||||
},
|
||||
{
|
||||
"doc": "docs/subsystems/typert.md",
|
||||
"symbol": "RemoteStreamHandle",
|
||||
"source": "packages/typert/protocol/src/types.ts"
|
||||
},
|
||||
{
|
||||
"doc": "docs/subsystems/typert.md",
|
||||
"symbol": "PeerScope",
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
"@deepseek-ai/dsh-api-workspace-controller/types": ["./packages/api/workspace-controller/src/types.ts"],
|
||||
"@deepseek-ai/dsh-typert-protocol": ["./packages/typert/protocol/src/index.ts"],
|
||||
"@deepseek-ai/dsh-typert-protocol/types": ["./packages/typert/protocol/src/types.ts"],
|
||||
"@deepseek-ai/dsh-typert-protocol/client": ["./packages/typert/protocol/src/client/index.ts"],
|
||||
"@deepseek-ai/dsh-typert-loader": ["./packages/typert/loader/src/index.ts"],
|
||||
"@deepseek-ai/dsh-session/invariant": ["./packages/core/session/src/invariant.ts"],
|
||||
"@deepseek-ai/dsh-typert-registry/types": ["./packages/typert/registry/src/types.ts"],
|
||||
|
||||
Reference in new issue
Block a user