@deepseek-ai/dsh-client-connection 0.1.5-rc.2 → 0.1.6-alpha.2

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/lib/index.js CHANGED
@@ -775,7 +775,7 @@ async function apply(ctx, config) {
775
775
  res.end(rejection === 401 ? "unauthorized" : "forbidden");
776
776
  return;
777
777
  }
778
- await bridge(req, res, fetchHandler, maxRequestBodyBytes);
778
+ await webCtx.waterfall("connection/request", req, res, () => bridge(req, res, fetchHandler, maxRequestBodyBytes));
779
779
  }
780
780
  };
781
781
  webCtx.effect(() => webCtx.webServer.register(route), "client-connection: /api route");
@@ -6,8 +6,8 @@ export type { MessageId } from '@deepseek-ai/dsh-llm/brand';
6
6
  export type { ContentBlock, StreamChunk } from '@deepseek-ai/dsh-llm/types';
7
7
  import type { RpcResponse, RpcResult } from '../rpc.ts';
8
8
  /**
9
- * Return the business result carried by a narrow fixture response.
10
- * @param response - fixture response to unwrap.
9
+ * Return the business result carried by an RPC response.
10
+ * @param response - RPC response to unwrap.
11
11
  * @returns the response's business result.
12
12
  */
13
13
  export declare function resultOf<T>(response: RpcResponse<T>): RpcResult<T>;
@@ -35,15 +35,21 @@ export interface ConnectionStateSource {
35
35
  /** Required services (none — this is the wire root). */
36
36
  export declare const inject: string[];
37
37
  /**
38
- * Carrier override installed on the page global before plugin boot. The served
39
- * web app leaves it unset and gets HTTP + WebSocket; a shell that owns a
40
- * different physical transport (the worker preview's postMessage tunnel)
41
- * provides both halves here instead of forking this plugin.
38
+ * Physical carrier selected when the Connection service is installed. The
39
+ * served web app omits it and gets HTTP + WebSocket; a shell that owns a
40
+ * different transport (the worker preview's postMessage tunnel) provides both
41
+ * halves instead of forking this plugin.
42
42
  */
43
43
  export interface ClientTransportHooks {
44
- /** Transport for generic unary RPC channels (the Typert gateway). */
45
- fetch: RpcFetch;
46
- /** Worker-local Gateway stream carrier; absent when the page uses the Gateway WebSocket. */
44
+ /**
45
+ * Already decoded logical RPC carrier. When present it replaces the HTTP
46
+ * caller outright: no envelopes, no `fetch`, no `openStream` (an in-process
47
+ * Host such as a test mock plugs in here).
48
+ */
49
+ rpc?: ClientConnectionRpc;
50
+ /** Transport for generic unary RPC channels (the Typert gateway); unused when `rpc` is present. */
51
+ fetch?: RpcFetch;
52
+ /** Worker-local Gateway stream carrier; absent when the page uses the Gateway WebSocket or `rpc` is present. */
47
53
  openStream?: RpcStreamOpen;
48
54
  /**
49
55
  * Bundle transport for the module system, present when the carrier also owns
@@ -60,6 +66,21 @@ export interface ClientTransportHooks {
60
66
  * transport can set this; served pages never carry the global at all.
61
67
  */
62
68
  ownsHost?: boolean;
69
+ /** HTTP origin of a shell-owned Host when its WebSocket uses a different page origin. */
70
+ streamBaseUrl?: string;
71
+ }
72
+ /** Browser location fields used to classify loopback authority. */
73
+ export interface ConnectionLocation {
74
+ readonly hostname: string;
75
+ }
76
+ /** Instance-local inputs for installing a Connection service. */
77
+ export interface ConnectionInstallOptions {
78
+ /** Explicit physical carrier; omit for the browser HTTP + WebSocket carrier. */
79
+ readonly transport?: ClientTransportHooks;
80
+ /** Reconnect timing overrides; omitted fields use controller defaults. */
81
+ readonly recovery?: ConnectionRecoveryConfig;
82
+ /** Page location; omit for a non-browser composition. */
83
+ readonly location?: ConnectionLocation;
63
84
  }
64
85
  /**
65
86
  * The ctx.connection service API. API Gateway supplies generation readiness
@@ -102,8 +123,14 @@ export interface ConnectionLoop {
102
123
  stop(): void;
103
124
  }
104
125
  /**
105
- * Client plugin body: pick physical carriers by page mode and provide ctx.connection.
106
- * @param ctx - client cordis context.
126
+ * Install one Context-owned Connection service from explicit composition inputs.
127
+ * @param ctx - client Cordis context.
128
+ * @param options - physical carrier, reconnect timing, and page location.
129
+ */
130
+ export declare function installConnection(ctx: Context, options?: ConnectionInstallOptions): void;
131
+ /**
132
+ * Client plugin body: read the page composition and install its Connection service.
133
+ * @param ctx - client Cordis context.
107
134
  */
108
135
  export declare function apply(ctx: Context): void;
109
136
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
1
  /** Host HTTP bridge for browser-client RPC. */
2
2
  import type { Context } from '@deepseek-ai/cordis';
3
+ import type { IncomingMessage, ServerResponse } from 'node:http';
3
4
  import z from '@deepseek-ai/schemastery';
4
5
  import { type ConnectionRecoveryConfig } from './recovery-config.ts';
5
6
  export type { ConnectionFetchMethod, ConnectionFetchHandler, ConnectionFetchRoute, ConnectionIndexRequest, ConnectionIndexResponse, ConnectionRpcEndpointMatcher, ConnectionRpcFailure, ConnectionRpcHandler, ConnectionRequestRejection, ConnectionRpcResult, ConnectionRequestBodyMode, ConnectionTrustRequest, ClientRequest, HostConnectionHandle, HostConnectionFetch, HostConnectionRpc, RpcMessage, ServerResponse, } from './rpc.ts';
@@ -9,6 +10,19 @@ export { HostConnectionService } from './rpc-host.ts';
9
10
  export { API_PATH } from './api-path.ts';
10
11
  /** Stable Cordis plugin name. */
11
12
  export declare const name = "client-connection";
13
+ declare module '@deepseek-ai/cordis' {
14
+ interface Events {
15
+ /**
16
+ * Admit or wrap an authenticated shared API request, including body transfer.
17
+ * Existing requests continue when a listener refuses subsequent requests.
18
+ * @param request - Authenticated incoming HTTP request.
19
+ * @param response - Response owned until the delegated bridge settles.
20
+ * @param next - Delegate to the next listener or the shared API bridge.
21
+ * @mode waterfall
22
+ */
23
+ 'connection/request'(request: IncomingMessage, response: ServerResponse, next: () => Promise<void>): Promise<void>;
24
+ }
25
+ }
12
26
  /** Services required before providing Connection. */
13
27
  export declare const inject: string[];
14
28
  /** Browser authentication, request limits, and connection recovery configuration. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-client-connection",
3
- "description": "Authenticated RPC transport, generation lifecycle, and browser fixture",
4
- "version": "0.1.5-rc.2",
3
+ "description": "Authenticated RPC transport and generation lifecycle",
4
+ "version": "0.1.6-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -35,8 +35,8 @@
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
37
  "zod": "^4.4.3",
38
- "@deepseek-ai/schemastery": "^3.18.2",
39
- "@deepseek-ai/dsh-credentials": "^0.1.5-rc.2"
38
+ "@deepseek-ai/dsh-credentials": "^0.1.6-alpha.2",
39
+ "@deepseek-ai/schemastery": "^3.18.2"
40
40
  },
41
41
  "files": [
42
42
  "lib/index.js",
@@ -47,17 +47,11 @@
47
47
  "@deepseek-ai/cordis": "^4.0.2"
48
48
  },
49
49
  "devDependencies": {
50
+ "@deepseek-ai/dsh-attachment": "^0.1.6-alpha.2",
50
51
  "@deepseek-ai/cordis": "^4.0.2",
51
- "@deepseek-ai/dsh-api-session-controller": "^0.1.5-rc.2",
52
- "@deepseek-ai/dsh-attachment": "^0.1.5-rc.2",
53
- "@deepseek-ai/dsh-brand": "^0.1.5-rc.2",
54
- "@deepseek-ai/dsh-commands": "^0.1.5-rc.2",
55
- "@deepseek-ai/dsh-host-directory-picker": "^0.1.5-rc.2",
56
- "@deepseek-ai/dsh-llm": "^0.1.5-rc.2",
57
- "@deepseek-ai/dsh-session": "^0.1.5-rc.2",
58
- "@deepseek-ai/dsh-settings": "^0.1.5-rc.2",
59
- "@deepseek-ai/dsh-tool-todo": "^0.1.5-rc.2",
60
- "@deepseek-ai/dsh-util-values": "^0.1.5-rc.2",
61
- "@deepseek-ai/dsh-host-webserver": "^0.1.5-rc.2"
52
+ "@deepseek-ai/dsh-brand": "^0.1.6-alpha.2",
53
+ "@deepseek-ai/dsh-host-webserver": "^0.1.6-alpha.2",
54
+ "@deepseek-ai/dsh-session": "^0.1.6-alpha.2",
55
+ "@deepseek-ai/dsh-llm": "^0.1.6-alpha.2"
62
56
  }
63
57
  }
@@ -1,64 +0,0 @@
1
- import { LlmAttemptId } from '@deepseek-ai/dsh-llm/brand';
2
- import type { SessionSeqCursor } from '@deepseek-ai/dsh-session/types';
3
- import type { JsonValue } from '@deepseek-ai/dsh-util-values';
4
- import type { ClientConnectionRpc } from '../rpc.ts';
5
- /** Assistant frame emitted by the standalone fixture; tests pin it to the controller wire type. */
6
- export type FixtureAssistantStreamFrame = {
7
- readonly type: 'start';
8
- readonly attemptId: ReturnType<typeof LlmAttemptId>;
9
- readonly revision: number;
10
- readonly startedAfterSeq: SessionSeqCursor;
11
- readonly turn: number;
12
- readonly step: number;
13
- } | {
14
- readonly type: 'chunk';
15
- readonly attemptId: ReturnType<typeof LlmAttemptId>;
16
- readonly revision: number;
17
- readonly index: number;
18
- readonly time: number;
19
- readonly chunk: JsonValue;
20
- } | {
21
- readonly type: 'end';
22
- readonly attemptId: ReturnType<typeof LlmAttemptId>;
23
- readonly revision: number;
24
- readonly index: number;
25
- readonly outcome: {
26
- readonly kind: 'committed';
27
- readonly eventType: 'assistant/message' | 'assistant/attempt';
28
- readonly seq: number;
29
- } | {
30
- readonly kind: 'abandoned';
31
- };
32
- };
33
- /** Deterministic fixture branches used by keyless Web assembly tests. */
34
- export interface FixtureOptions {
35
- /** Start with no real Workspace or Session. */
36
- empty?: boolean;
37
- /** Reject every prompt before appending its user event. */
38
- rejectPrompt?: boolean;
39
- /** Publish the Session but fail its Workspace account write. */
40
- failWorkspaceAttach?: boolean;
41
- /** Publish and frame the Session, then throw instead of returning create. */
42
- dropSessionCreateResponse?: boolean;
43
- /** Order of the two successful create frames. */
44
- createFrameOrder?: 'session-first' | 'workspace-first';
45
- /** Announce one Agent write to `notes/demo.txt` shortly after a `workspaceFiles/changes` stream opens. */
46
- fileChanges?: boolean;
47
- }
48
- /** Fixture RPC face over one in-memory state graph. */
49
- export interface FixtureWorld {
50
- /** Generic Remote caller for the endpoints business services own. */
51
- readonly rpc: ClientConnectionRpc;
52
- }
53
- /**
54
- * Build the fixture RPC face over one in-memory state graph.
55
- * @param options - fixture branches for empty state and failure timing.
56
- * @returns the Remote RPC face.
57
- */
58
- export declare function createFixtureFaces(options?: FixtureOptions): FixtureWorld;
59
- /**
60
- * Build the browser fixture transport from the current page's query switches.
61
- * @returns an in-memory Connection RPC transport.
62
- */
63
- export declare function createFixtureConnectionRpc(): ClientConnectionRpc;
64
- //# sourceMappingURL=fixture.d.ts.map