dsh-interconnect 0.1.0

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.
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Wire contracts for `@deepseek-ai/dsh-interconnect`.
3
+ * The transport reuses the Connection RPC envelope (`ClientRequest` /
4
+ * `ServerResponse` from `@deepseek-ai/dsh-host-apiproxy/api`); this module
5
+ * defines only the business payloads that ride inside that envelope.
6
+ * @module @deepseek-ai/dsh-interconnect
7
+ */
8
+ /**
9
+ * Logical HTTP route prefix this service owns. Requests reach endpoints as
10
+ * `<baseURL>/interconnect/<endpoint>`.
11
+ */
12
+ export declare const INTERCONNECT_CHANNEL = "/interconnect";
13
+ /**
14
+ * Credential reference holding the shared auth token. Both halves of a link
15
+ * must resolve the same value: inbound requests are rejected unless their
16
+ * `Authorization: Bearer <token>` matches this secret, and outbound requests
17
+ * send it. An unconfigured token fails closed on the inbound side.
18
+ */
19
+ export declare const INTERCONNECT_TOKEN_REF = "DSH_INTERCONNECT_TOKEN";
20
+ /**
21
+ * Business payload for the `send` endpoint: deliver one text message to one
22
+ * live session of the receiving instance.
23
+ */
24
+ export interface SendPayload {
25
+ /** Target session id on the receiving instance. */
26
+ readonly sessionId: string;
27
+ /** Message text delivered to the peer session's inbox. */
28
+ readonly text: string;
29
+ }
30
+ /** Business result of a `send` endpoint call. */
31
+ export interface SendResult {
32
+ /** True when the target session is live on the receiving instance and the message was delivered. */
33
+ readonly delivered: boolean;
34
+ /** Echoed receiver instance id (diagnostic; never trusted for routing). */
35
+ readonly instance: string;
36
+ }
37
+ /** Business result of a `ping` endpoint call. */
38
+ export interface PingResult {
39
+ /** Always true for an authenticated, live receiver. */
40
+ readonly pong: true;
41
+ /** The receiving instance's self-reported id. */
42
+ readonly instance: string;
43
+ }
44
+ /** Outbound delivery request: receiver origin plus a `send` business payload. */
45
+ export interface SendRequest {
46
+ /** Receiver origin, e.g. `http://127.0.0.1:3080`. */
47
+ readonly baseUrl: string;
48
+ readonly sessionId: string;
49
+ readonly text: string;
50
+ }
51
+ /**
52
+ * One serializable lifecycle fact pushed from an emitting instance to its
53
+ * peers. `kind` discriminates the union; the remaining fields are the compact
54
+ * facts extractable from the source event without serializing live objects.
55
+ */
56
+ export type EventNotification = {
57
+ readonly kind: 'agent/created';
58
+ readonly sessionId: string;
59
+ } | {
60
+ readonly kind: 'agent/disposed';
61
+ readonly sessionId: string;
62
+ } | {
63
+ readonly kind: 'agent/status';
64
+ readonly sessionId: string;
65
+ readonly status: 'idle' | 'running';
66
+ } | {
67
+ readonly kind: 'session/created';
68
+ readonly sessionId: string;
69
+ readonly parentSessionId?: string;
70
+ } | {
71
+ readonly kind: 'session/disposed';
72
+ readonly sessionId: string;
73
+ } | {
74
+ readonly kind: 'subagent/end';
75
+ readonly provider: string;
76
+ readonly childSessionId: string;
77
+ readonly stopReason: string;
78
+ };
79
+ /**
80
+ * Wire payload for the `event` endpoint: the pushed fact plus the emitting
81
+ * instance's self-reported id, so a many-upstream receiver can attribute it.
82
+ */
83
+ export interface EventPayload {
84
+ /** Emitting instance's self-reported id. */
85
+ readonly sender: string;
86
+ /** The serialized lifecycle fact. */
87
+ readonly notification: EventNotification;
88
+ }
89
+ /**
90
+ * One text frame exchanged over a persistent WebSocket peer link. `hello`
91
+ * opens a link with the dialing side's identity; `event` pushes one
92
+ * notification in either direction. Native ws ping/pong carries the heartbeat,
93
+ * so no application-level keepalive frame exists.
94
+ */
95
+ export type LinkFrame = {
96
+ readonly type: 'hello';
97
+ readonly sender: string;
98
+ } | {
99
+ readonly type: 'event';
100
+ readonly notification: EventNotification;
101
+ };
102
+ /**
103
+ * Handle to one established outbound WebSocket peer link. `close` tears the
104
+ * socket down and cancels reconnection; `peer` records the dialed receiver.
105
+ */
106
+ export interface WebSocketLinkHandle {
107
+ /** The dialed peer origin. */
108
+ readonly peer: string;
109
+ /** Terminate the socket and stop reconnect attempts. */
110
+ close(): void;
111
+ }
112
+ /** Service config bound by the Composition loader. */
113
+ export interface Config {
114
+ /** Self-reported id of this instance, echoed in ping/send results for diagnostics. */
115
+ readonly instanceId: string;
116
+ /** Request timeout for outbound deliveries, in milliseconds. */
117
+ readonly requestTimeoutMs: number;
118
+ /**
119
+ * Peer instance origins to fan local events out to at startup. A runtime
120
+ * `subscribe` can extend the set without restart; an unset list fans nothing
121
+ * out until a peer subscribes.
122
+ */
123
+ readonly peers?: string[];
124
+ /**
125
+ * How an inbound `send` message reaches its target session.
126
+ * - `followup` wakes the target agent into a new turn carrying the message.
127
+ * - `inject` seeds model-facing context without waking the agent (it is
128
+ * claimed at the next step boundary, and may miss a step already claimed).
129
+ */
130
+ readonly delivery?: 'followup' | 'inject';
131
+ }
132
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/interconnect/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kBAAkB,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,2BAA2B,CAAA;AAE9D;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,iDAAiD;AACjD,MAAM,WAAW,UAAU;IACzB,oGAAoG;IACpG,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED,iDAAiD;AACjD,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,qDAA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;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAA;CAAE,CAAA;AAExE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,wDAAwD;IACxD,KAAK,IAAI,IAAI,CAAA;CACd;AAED,sDAAsD;AACtD,MAAM,WAAW,MAAM;IACrB,sFAAsF;IACtF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAA;CAC1C"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Model-facing tools for cross-instance message handoff: `interconnect_send`
3
+ * delivers one text message to a live session on a peer DSH instance, and
4
+ * `interconnect_ping` probes a peer's liveness and identity.
5
+ *
6
+ * The tools consume the host-plane `interconnect` service and publish nothing
7
+ * themselves, so this row sits as an ordinary tool plugin in a preset while
8
+ * the service it reaches stays host-side (the same split `tool-goal` uses
9
+ * against `goals`).
10
+ * @module @deepseek-ai/dsh-tool-interconnect
11
+ */
12
+ import { Context } from '@deepseek-ai/cordis';
13
+ /** Services required before the tools can register. */
14
+ export declare const inject: string[];
15
+ /**
16
+ * Register the two tool surfaces. Registration is idempotent per fiber; the
17
+ * tools unregister with the owning fiber.
18
+ * @param ctx - connection context carrying the interconnect service and the tool registry.
19
+ */
20
+ export declare function apply(ctx: Context): void;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tool-interconnect/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAK7C,uDAAuD;AACvD,eAAO,MAAM,MAAM,UAA4B,CAAA;AAE/C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAoFxC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@deepseek-ai/dsh-tool-interconnect`.
3
+ * @module @deepseek-ai/dsh-tool-interconnect/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "tool-interconnect-invariant";
8
+ /** Service required before the companion can register. */
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 @@
1
+ {"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../../src/tool-interconnect/invariant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,oCAAoC;AACpC,eAAO,MAAM,IAAI,gCAAgC,CAAA;AACjD,0DAA0D;AAC1D,eAAO,MAAM,MAAM,UAAiB,CAAA;AAWpC;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,OAAO,KAAG,OAAO,CAAC,MAAM,IAAI,CACU,CAAA"}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "dsh-interconnect",
3
+ "description": "Cross-instance message/event handoff plugins for DeepSeek Harness (DSH): interconnect service + model-facing tools",
4
+ "version": "0.1.0",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "lib/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/types/index.d.ts",
11
+ "default": "./lib/index.js"
12
+ },
13
+ "./interconnect": {
14
+ "types": "./lib/types/interconnect/index.d.ts",
15
+ "default": "./lib/interconnect/index.js"
16
+ },
17
+ "./tool-interconnect": {
18
+ "types": "./lib/types/tool-interconnect/index.d.ts",
19
+ "default": "./lib/tool-interconnect/index.js"
20
+ },
21
+ "./cordis.patch.yml": "./cordis.patch.yml",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "dsh": {
25
+ "bundle": {
26
+ "patch": "./cordis.patch.yml"
27
+ }
28
+ },
29
+ "files": [
30
+ "lib",
31
+ "cordis.patch.yml",
32
+ "dsh.plugin.json",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "scripts": {
37
+ "build": "node build.mjs",
38
+ "typecheck": "tsc --noEmit",
39
+ "test": "vitest run",
40
+ "check": "pnpm run typecheck && pnpm run test && pnpm run build"
41
+ },
42
+ "peerDependencies": {
43
+ "@deepseek-ai/cordis": "*",
44
+ "@deepseek-ai/dsh-agent": "*",
45
+ "@deepseek-ai/dsh-credentials": "*",
46
+ "@deepseek-ai/dsh-llm": "*",
47
+ "@deepseek-ai/dsh-session": "*",
48
+ "@deepseek-ai/dsh-subagent": "*",
49
+ "@deepseek-ai/dsh-host-apiproxy": "*",
50
+ "@deepseek-ai/dsh-host-webserver": "*",
51
+ "@deepseek-ai/dsh-tools": "*",
52
+ "@deepseek-ai/dsh-invariants": "*",
53
+ "@deepseek-ai/schemastery": "*",
54
+ "ws": "*"
55
+ },
56
+ "devDependencies": {
57
+ "@deepseek-ai/cordis": "link:../dsh/vendor/cordis",
58
+ "@deepseek-ai/schemastery": "link:../dsh/vendor/schemastery",
59
+ "@deepseek-ai/dsh-agent": "link:../dsh/packages/core/agent",
60
+ "@deepseek-ai/dsh-credentials": "link:../dsh/packages/credentials/credentials",
61
+ "@deepseek-ai/dsh-llm": "link:../dsh/packages/llm/llm",
62
+ "@deepseek-ai/dsh-session": "link:../dsh/packages/core/session",
63
+ "@deepseek-ai/dsh-subagent": "link:../dsh/packages/subagent/subagent",
64
+ "@deepseek-ai/dsh-host-apiproxy": "link:../dsh/packages/host/apiproxy",
65
+ "@deepseek-ai/dsh-host-webserver": "link:../dsh/packages/host/webserver",
66
+ "@deepseek-ai/dsh-tools": "link:../dsh/packages/core/tools",
67
+ "@deepseek-ai/dsh-invariants": "link:../dsh/packages/runtime-diagnostics/invariants",
68
+ "@deepseek-ai/dsh-system-prompt": "link:../dsh/packages/core/system-prompt",
69
+ "@types/node": "^24.0.0",
70
+ "@types/ws": "^8.18.1",
71
+ "esbuild": "^0.25.0",
72
+ "typescript": "^6.0.3",
73
+ "vitest": "^4.1.8",
74
+ "ws": "^8.21.0"
75
+ }
76
+ }