dsh-interconnect 0.11.15 → 0.11.16

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.
@@ -80,6 +80,8 @@ When a send/reply reports `delivered: false`, read `reason`:
80
80
  choose a live target instead.
81
81
  - `session-owned-by-subagent` — the session belongs to a subagent and its
82
82
  parent owns delivery; reach it through the parent.
83
+ - `message-too-large` — the message is larger than the peer link can carry
84
+ (1 MiB once encoded); shorten the text instead of retrying it unchanged.
83
85
  - `no-sender-known` — a `reply` was attempted for a local session that never
84
86
  received a sender-carrying interconnect message, or whose recorded sender was
85
87
  forgotten by a receiver restart; establish contact with `interconnect_send`
package/dsh.plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-interconnect",
3
3
  "description": "Cross-instance message/event handoff for DeepSeek Harness (DSH): WebSocket link, model-facing tools, and companion skill.",
4
- "version": "0.11.15",
4
+ "version": "0.11.16",
5
5
  "entry": {
6
6
  "name": "dsh-interconnect/interconnect",
7
7
  "inject": ["agents", "credentials"]
package/lib/index.js CHANGED
@@ -837,6 +837,7 @@ var LINK_HANDSHAKE_TIMEOUT_MS = 1e4;
837
837
  var LINK_CHANNEL = "/interconnect/link";
838
838
  var MAX_REQUEST_ID_CHARS = 256;
839
839
  var MAX_LISTED_SESSIONS = 100;
840
+ var frameFitsLink = (frame) => Buffer.byteLength(JSON.stringify(frame), "utf8") <= MAX_LINK_FRAME_BYTES;
840
841
  var rowBytes = (row) => Buffer.byteLength(JSON.stringify(row), "utf8") + 1;
841
842
  var notificationSchema = Schema.union([
842
843
  Schema.object({ kind: Schema.const("agent/created").required(), sessionId: Schema.string().required() }),
@@ -1123,22 +1124,30 @@ var InterconnectService = class extends Service {
1123
1124
  * Send a `msg` frame over the live link to a peer and resolve with its
1124
1125
  * correlated `msg-result`. Undefined when the peer has no live link here
1125
1126
  * (not configured, or the link is down) — sends can only address configured+
1126
- * connected peers by design.
1127
+ * connected peers by design — and a `message-too-large` result when the
1128
+ * encoded frame would not fit the link.
1127
1129
  */
1128
1130
  async msgRequest(instanceId, kind, payload) {
1129
1131
  const state = this.linkStates.get(instanceId);
1130
1132
  if (state === void 0 || !state.writable()) return void 0;
1131
1133
  const reqId = `m${++this.reqIdCounter}-${randomUUID()}`;
1132
- const message = {
1133
- kind,
1134
- sessionId: payload.sessionId,
1135
- text: payload.text,
1136
- ...payload.sender === void 0 ? {} : { sender: payload.sender },
1137
- ...payload.delivery === void 0 ? {} : { delivery: payload.delivery },
1138
- ...payload.resume === void 0 ? {} : { resume: payload.resume }
1134
+ const frame = {
1135
+ type: "msg",
1136
+ reqId,
1137
+ message: {
1138
+ kind,
1139
+ sessionId: payload.sessionId,
1140
+ text: payload.text,
1141
+ ...payload.sender === void 0 ? {} : { sender: payload.sender },
1142
+ ...payload.delivery === void 0 ? {} : { delivery: payload.delivery },
1143
+ ...payload.resume === void 0 ? {} : { resume: payload.resume }
1144
+ }
1139
1145
  };
1146
+ if (!frameFitsLink(frame)) {
1147
+ return { delivered: false, instance: instanceId, reason: "message-too-large" };
1148
+ }
1140
1149
  return this.waitForResult(reqId, "msg", (failure) => {
1141
- const wrote = state.sendFrame({ type: "msg", reqId, message });
1150
+ const wrote = state.sendFrame(frame);
1142
1151
  if (!wrote) failure(new Error(`interconnect: peer link to ${instanceId} closed while sending`));
1143
1152
  });
1144
1153
  }
@@ -837,6 +837,7 @@ var LINK_HANDSHAKE_TIMEOUT_MS = 1e4;
837
837
  var LINK_CHANNEL = "/interconnect/link";
838
838
  var MAX_REQUEST_ID_CHARS = 256;
839
839
  var MAX_LISTED_SESSIONS = 100;
840
+ var frameFitsLink = (frame) => Buffer.byteLength(JSON.stringify(frame), "utf8") <= MAX_LINK_FRAME_BYTES;
840
841
  var rowBytes = (row) => Buffer.byteLength(JSON.stringify(row), "utf8") + 1;
841
842
  var notificationSchema = Schema.union([
842
843
  Schema.object({ kind: Schema.const("agent/created").required(), sessionId: Schema.string().required() }),
@@ -1123,22 +1124,30 @@ var InterconnectService = class extends Service {
1123
1124
  * Send a `msg` frame over the live link to a peer and resolve with its
1124
1125
  * correlated `msg-result`. Undefined when the peer has no live link here
1125
1126
  * (not configured, or the link is down) — sends can only address configured+
1126
- * connected peers by design.
1127
+ * connected peers by design — and a `message-too-large` result when the
1128
+ * encoded frame would not fit the link.
1127
1129
  */
1128
1130
  async msgRequest(instanceId, kind, payload) {
1129
1131
  const state = this.linkStates.get(instanceId);
1130
1132
  if (state === void 0 || !state.writable()) return void 0;
1131
1133
  const reqId = `m${++this.reqIdCounter}-${randomUUID()}`;
1132
- const message = {
1133
- kind,
1134
- sessionId: payload.sessionId,
1135
- text: payload.text,
1136
- ...payload.sender === void 0 ? {} : { sender: payload.sender },
1137
- ...payload.delivery === void 0 ? {} : { delivery: payload.delivery },
1138
- ...payload.resume === void 0 ? {} : { resume: payload.resume }
1134
+ const frame = {
1135
+ type: "msg",
1136
+ reqId,
1137
+ message: {
1138
+ kind,
1139
+ sessionId: payload.sessionId,
1140
+ text: payload.text,
1141
+ ...payload.sender === void 0 ? {} : { sender: payload.sender },
1142
+ ...payload.delivery === void 0 ? {} : { delivery: payload.delivery },
1143
+ ...payload.resume === void 0 ? {} : { resume: payload.resume }
1144
+ }
1139
1145
  };
1146
+ if (!frameFitsLink(frame)) {
1147
+ return { delivered: false, instance: instanceId, reason: "message-too-large" };
1148
+ }
1140
1149
  return this.waitForResult(reqId, "msg", (failure) => {
1141
- const wrote = state.sendFrame({ type: "msg", reqId, message });
1150
+ const wrote = state.sendFrame(frame);
1142
1151
  if (!wrote) failure(new Error(`interconnect: peer link to ${instanceId} closed while sending`));
1143
1152
  });
1144
1153
  }