@mininglamp-oss/octo-runtime 1.0.0 → 1.0.1

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.
Files changed (101) hide show
  1. package/apps/cli/dist/build-info.json +3 -2
  2. package/apps/cli/dist/help.js +15 -6
  3. package/apps/cli/dist/state.d.ts +1 -0
  4. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.d.ts +4 -1
  5. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +14 -7
  6. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  7. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +2 -2
  8. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +5 -4
  9. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  10. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +3 -3
  11. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +5 -1
  12. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  13. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +2 -1
  14. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  15. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +3 -3
  16. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +3 -2
  17. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  18. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +19 -6
  19. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  20. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +1 -1
  21. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  22. package/node_modules/@mininglamp-oss/octo-runtime-adapter-host/dist/host-run-service.d.ts +2 -1
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-host/dist/host-run-service.js +29 -11
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-host/dist/index.js +45 -17
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-host/dist/rpc.d.ts +2 -1
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-host/dist/rpc.js +90 -18
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-host/dist/runtime-configuration.js +32 -1
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-host/dist/socket-server.js +6 -1
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-host/package.json +16 -16
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +1 -1
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +1 -1
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +2 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +4 -4
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +1 -1
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +1 -1
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +1 -1
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +2 -1
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +3 -1
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +5 -3
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/line-limit.js +15 -4
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/native.d.ts +4 -1
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/native.js +29 -4
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.d.ts +1 -1
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.js +17 -11
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  52. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +3 -2
  53. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +15 -6
  54. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.d.ts +1 -0
  55. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +8 -8
  56. package/node_modules/@mininglamp-oss/octo-runtime-core/package.json +2 -2
  57. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  58. package/node_modules/@mininglamp-oss/octo-runtime-daemon/dist/runtime/run-stream.js +29 -12
  59. package/node_modules/@mininglamp-oss/octo-runtime-daemon/dist/server.js +7 -1
  60. package/node_modules/@mininglamp-oss/octo-runtime-daemon/package.json +17 -17
  61. package/node_modules/@mininglamp-oss/octo-runtime-daemon-app/package.json +7 -7
  62. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.d.ts +34 -0
  63. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.js +124 -0
  64. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +152 -9
  65. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.d.ts +4 -0
  66. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.js +32 -0
  67. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +16 -0
  68. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +54 -4
  69. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.js +4 -1
  70. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.d.ts +5 -0
  71. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.js +8 -2
  72. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +49 -2
  73. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.d.ts +4 -1
  74. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.js +94 -15
  75. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/normalize.d.ts +1 -0
  76. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/normalize.js +10 -5
  77. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +5 -1
  78. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +19 -2
  79. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +30 -4
  80. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +7 -7
  81. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +3 -2
  82. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +6 -6
  83. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/index-DiPc-ipL.js +74 -0
  84. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
  85. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  86. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +4 -0
  87. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +30 -1
  88. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +2 -1
  89. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +1 -0
  90. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +1 -0
  91. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +3 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-size.js +2 -1
  93. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +1 -1
  94. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +51 -4
  95. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/stream-limits.d.ts +27 -0
  96. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/stream-limits.js +56 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  98. package/node_modules/ws/lib/websocket.js +17 -3
  99. package/node_modules/ws/package.json +1 -1
  100. package/package.json +27 -27
  101. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/index-B6Yp4xkI.js +0 -76
@@ -7,7 +7,7 @@ export { HostRunService } from "./host-run-service.js";
7
7
  export { readAdapterConfigurations } from "./runtime-configuration.js";
8
8
  export { startHostSocketServer, streamHostRun } from "./socket-server.js";
9
9
  export { prepareRunContext } from "./execution-preparation.js";
10
- import { createInputInvoke, assertInvokeRequestSize, assertProtocolSupport, assertAdapterProtocolSupport, assertHostFrame, assertHostFrameIdentity, assertNativeInteractionResponse, resolveHostInvokeOptions, protocolError, assertCanonicalEvent, assertInteractionResponse, assertInvokeRequest, failurePayload, isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
10
+ import { createInputInvoke, assertInvokeRequestSize, assertProtocolSupport, assertAdapterProtocolSupport, assertHostFrame, assertHostFrameIdentity, assertNativeInteractionResponse, resolveHostInvokeOptions, protocolError, assertCanonicalEvent, assertInteractionResponse, assertInvokeRequest, failurePayload, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError, isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
11
11
  import { InvocationExperience } from "./experience.js";
12
12
  import { withModelContexts } from "./model-input.js";
13
13
  import { noopRuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
@@ -188,7 +188,7 @@ export class AdapterHost {
188
188
  });
189
189
  const frozenRequest = withModelContexts({ ...run.request, signal: request.signal });
190
190
  run.request = undefined;
191
- return this.#streamInvocation(adapterType, frozenRequest, receipt);
191
+ return this.#streamInvocation(adapterType, frozenRequest, receipt, resolveStreamLimitPolicy(environment.streamLimits));
192
192
  }
193
193
  catch (error) {
194
194
  this.#log("warn", "invoke.rejected", {
@@ -198,7 +198,7 @@ export class AdapterHost {
198
198
  throw error;
199
199
  }
200
200
  }
201
- async *#streamInvocation(adapterType, request, receipt) {
201
+ async *#streamInvocation(adapterType, request, receipt, streamLimits) {
202
202
  const started = Date.now();
203
203
  const identity = {
204
204
  run_id: request.runId,
@@ -221,8 +221,12 @@ export class AdapterHost {
221
221
  assertHostFrame(result);
222
222
  assertHostFrameIdentity(result, receipt);
223
223
  const size = Buffer.byteLength(JSON.stringify(result));
224
- if (size > 256 * 1024)
225
- throw new Error("STREAM_EVENT_TOO_LARGE");
224
+ if (size > streamLimits.hostFrameMaxBytes)
225
+ throw streamCapacityError("HOST_FRAME_TOO_LARGE", {
226
+ boundary: "adapter_host.frame",
227
+ measuredBytes: size,
228
+ limitBytes: streamLimits.hostFrameMaxBytes
229
+ });
226
230
  seq++;
227
231
  return result;
228
232
  };
@@ -230,8 +234,8 @@ export class AdapterHost {
230
234
  let failureCode;
231
235
  const pendingInteractions = new Set();
232
236
  const source = receipt.protocol_mode === "canonical"
233
- ? this.#invokeCanonical(adapterType, request)
234
- : this.#invokeProvider(adapterType, request, "native");
237
+ ? this.#invokeCanonical(adapterType, request, streamLimits)
238
+ : this.#invokeProvider(adapterType, request, "native", streamLimits);
235
239
  try {
236
240
  yield frame({ kind: "control", control: { type: "state", state: "running" } });
237
241
  let pending = source.next();
@@ -298,6 +302,17 @@ export class AdapterHost {
298
302
  this.#active.get(request.invocationId)?.abort(error);
299
303
  await source.return(undefined);
300
304
  state = { type: "state", state: "failed" };
305
+ const causeCode = errorCode(error);
306
+ const controlCode = isStreamCapacityReason(causeCode) ? causeCode : "HOST_FRAME_INVALID";
307
+ failureCode = controlCode;
308
+ const failure = isStreamCapacityReason(causeCode)
309
+ ? failurePayload({ code: causeCode, ...capacityFailureDetails(error) }, {
310
+ stage: "adapter_host.frame",
311
+ defaultDomain: "adapter",
312
+ runId: request.runId,
313
+ source: { component: "octo-runtime", adapter: adapterType }
314
+ }).failure
315
+ : undefined;
301
316
  for (const requestId of pendingInteractions)
302
317
  yield {
303
318
  ...receipt,
@@ -311,8 +326,9 @@ export class AdapterHost {
311
326
  seq: ++seq,
312
327
  control: {
313
328
  type: "error",
314
- code: "HOST_FRAME_INVALID",
315
- message: "Host output violated the selected stream contract"
329
+ code: controlCode,
330
+ message: "Host output violated the selected stream contract",
331
+ ...(failure ? { failure } : {})
316
332
  }
317
333
  };
318
334
  yield { ...receipt, kind: "control", seq: ++seq, control: state };
@@ -339,9 +355,9 @@ export class AdapterHost {
339
355
  }
340
356
  }
341
357
  }
342
- async *#invokeCanonical(adapterType, request) {
358
+ async *#invokeCanonical(adapterType, request, streamLimits) {
343
359
  const experience = new InvocationExperience();
344
- const provider = this.#invokeProvider(adapterType, request);
360
+ const provider = this.#invokeProvider(adapterType, request, "canonical", streamLimits);
345
361
  let pending = provider.next();
346
362
  void pending.catch(() => undefined);
347
363
  let finalBody = false;
@@ -386,7 +402,7 @@ export class AdapterHost {
386
402
  await provider.return(undefined);
387
403
  }
388
404
  }
389
- async *#invokeProvider(adapterType, request, protocolMode = "canonical") {
405
+ async *#invokeProvider(adapterType, request, protocolMode = "canonical", streamLimits = resolveStreamLimitPolicy(undefined)) {
390
406
  this.#log("info", "invoke.started", {
391
407
  run_id: request.runId,
392
408
  invocation_id: request.invocationId,
@@ -435,6 +451,7 @@ export class AdapterHost {
435
451
  let messageNumber = 0;
436
452
  const context = {
437
453
  protocolMode,
454
+ streamLimits,
438
455
  reportConversion: () => {
439
456
  if (protocolMode === "native")
440
457
  throw protocolError("EXECUTION_PROTOCOL_MISMATCH", "Native execution invoked a canonical converter");
@@ -634,6 +651,7 @@ export class AdapterHost {
634
651
  message: errorMessage(error),
635
652
  adapterType,
636
653
  ...(errorCode(error) ? { code: errorCode(error) } : {}),
654
+ ...capacityFailureDetails(error),
637
655
  ...watchdogFailureDetails(error)
638
656
  }, request.workdir, {
639
657
  stage: "adapter.invoke",
@@ -661,17 +679,19 @@ export class AdapterHost {
661
679
  controller.abort(error);
662
680
  await waitCleanup().catch(() => undefined);
663
681
  if (protocolMode === "native") {
682
+ const nativeFailureCode = errorCode(error);
664
683
  if (!userCancelled)
665
684
  yield {
666
685
  kind: "control",
667
686
  control: {
668
687
  type: "error",
669
- code: error instanceof Error &&
670
- "code" in error &&
671
- error.code === "HOST_ENDED_WITHOUT_TERMINAL"
688
+ code: nativeFailureCode === "HOST_ENDED_WITHOUT_TERMINAL"
672
689
  ? "HOST_ENDED_WITHOUT_TERMINAL"
673
- : "HOST_EXECUTION_FAILED",
674
- message: String(failure.message)
690
+ : isStreamCapacityReason(nativeFailureCode)
691
+ ? nativeFailureCode
692
+ : "HOST_EXECUTION_FAILED",
693
+ message: String(failure.message),
694
+ ...(isStreamCapacityReason(nativeFailureCode) ? { failure: failure.failure } : {})
675
695
  }
676
696
  };
677
697
  yield {
@@ -843,6 +863,14 @@ function errorCode(error) {
843
863
  ? error.code
844
864
  : undefined;
845
865
  }
866
+ function capacityFailureDetails(error) {
867
+ if (!error || typeof error !== "object")
868
+ return {};
869
+ const input = error;
870
+ return Object.fromEntries(["boundary", "measuredBytes", "limitBytes", "itemCount", "limitItems"]
871
+ .filter((key) => Object.hasOwn(input, key))
872
+ .map((key) => [key, input[key]]));
873
+ }
846
874
  async function waitForNext(pending, signal) {
847
875
  let onAbort = () => { };
848
876
  try {
@@ -37,10 +37,11 @@ export declare class AdapterHostRpcServer {
37
37
  export declare class AdapterHostRpcClient implements AdapterHostRpc {
38
38
  #private;
39
39
  readonly invoke: InputInvoke;
40
- constructor({ input, output, trace }: {
40
+ constructor({ input, output, trace, maximumInputBytes }: {
41
41
  input: Readable;
42
42
  output: Writable;
43
43
  trace?: RpcTrace;
44
+ maximumInputBytes?: number;
44
45
  });
45
46
  /** Send an ordinary JSON-RPC request and await the matching response by random ID. */
46
47
  request<T = unknown>(method: string, params?: JsonRecord, signal?: AbortSignal): Promise<T>;
@@ -1,27 +1,51 @@
1
1
  import { createInterface } from "node:readline";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { watchLineLimit, readBoundedLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
4
- import { createInputInvoke, INVOKE_REQUEST_MAX_BYTES, assertJsonByteLimit, assertHostFrame, assertHostRunReceipt, assertHostFrameIdentity, isHostTerminal } from "@mininglamp-oss/octo-runtime-protocol";
4
+ import { createInputInvoke, HOST_RPC_MAX_LINE_BYTES, INVOKE_REQUEST_MAX_BYTES, resolveStreamLimitPolicy, streamCapacityError, assertJsonByteLimit, assertHostFrame, assertHostRunReceipt, assertHostFrameIdentity, isHostTerminal } from "@mininglamp-oss/octo-runtime-protocol";
5
5
  /** A single-consumer async queue: producers `push`, one consumer iterates, and `close` ends the stream (optionally with an error). */
6
6
  class AsyncQueue {
7
+ limits;
7
8
  #items = [];
8
9
  #bytes = 0;
9
10
  #waiters = [];
10
11
  #closed = false;
11
12
  #error;
13
+ constructor(limits) {
14
+ this.limits = limits;
15
+ }
12
16
  push(value) {
13
17
  if (this.#closed)
14
18
  return;
15
19
  const bytes = Buffer.byteLength(JSON.stringify(value));
16
- if (bytes > 256 * 1024 || this.#items.length >= 4096 || this.#bytes + bytes > 4 * 1024 * 1024) {
17
- this.close(new Error("STREAM_BUFFER_OVERFLOW"));
20
+ if (bytes > this.limits.itemMaxBytes) {
21
+ this.close(streamCapacityError("STREAM_QUEUE_ITEM_TOO_LARGE", {
22
+ boundary: this.limits.boundary,
23
+ measuredBytes: bytes,
24
+ limitBytes: this.limits.itemMaxBytes
25
+ }));
26
+ return;
27
+ }
28
+ if (this.#items.length >= this.limits.maxItems) {
29
+ this.close(streamCapacityError("STREAM_QUEUE_ITEMS_EXCEEDED", {
30
+ boundary: this.limits.boundary,
31
+ itemCount: this.#items.length + 1,
32
+ limitItems: this.limits.maxItems
33
+ }));
34
+ return;
35
+ }
36
+ if (this.#bytes + bytes > this.limits.maxBytes) {
37
+ this.close(streamCapacityError("STREAM_QUEUE_BYTES_EXCEEDED", {
38
+ boundary: this.limits.boundary,
39
+ measuredBytes: this.#bytes + bytes,
40
+ limitBytes: this.limits.maxBytes
41
+ }));
18
42
  return;
19
43
  }
20
44
  const waiter = this.#waiters.shift();
21
45
  if (waiter)
22
46
  waiter.resolve({ value, done: false });
23
47
  else {
24
- this.#items.push(value);
48
+ this.#items.push({ value, bytes });
25
49
  this.#bytes += bytes;
26
50
  }
27
51
  }
@@ -38,10 +62,10 @@ class AsyncQueue {
38
62
  }
39
63
  }
40
64
  next() {
41
- const value = this.#items.shift();
42
- if (value !== undefined) {
43
- this.#bytes -= Buffer.byteLength(JSON.stringify(value));
44
- return Promise.resolve({ value, done: false });
65
+ const item = this.#items.shift();
66
+ if (item !== undefined) {
67
+ this.#bytes -= item.bytes;
68
+ return Promise.resolve({ value: item.value, done: false });
45
69
  }
46
70
  if (this.#error)
47
71
  return Promise.reject(this.#error);
@@ -204,7 +228,8 @@ export class AdapterHostRpcServer {
204
228
  signal: controller.signal,
205
229
  ...(method === "invoke.with-environment"
206
230
  ? {
207
- executionEnvOverrides: params.executionEnvOverrides
231
+ executionEnvOverrides: params.executionEnvOverrides,
232
+ streamLimits: resolveStreamLimitPolicy(params.streamLimits)
208
233
  }
209
234
  : {})
210
235
  });
@@ -282,7 +307,10 @@ export class AdapterHostRpcServer {
282
307
  this.#send({
283
308
  jsonrpc: "2.0",
284
309
  method: "invoke.done",
285
- params: { invocationId, error: { message: errorMessage(error) } }
310
+ params: {
311
+ invocationId,
312
+ error: { message: errorMessage(error), ...safeStreamErrorDetails(error) }
313
+ }
286
314
  });
287
315
  }
288
316
  finally {
@@ -334,11 +362,20 @@ export class AdapterHostRpcClient {
334
362
  #pending = new Map();
335
363
  #invocations = new Map();
336
364
  #closedError;
337
- constructor({ input, output, trace }) {
365
+ constructor({ input, output, trace, maximumInputBytes = HOST_RPC_MAX_LINE_BYTES }) {
338
366
  this.#send = writer(output, trace, (error) => this.close(error));
339
- const removeGuard = watchLineLimit(input, 512 * 1024, (error) => {
340
- this.close(error);
341
- input.destroy(error);
367
+ const removeGuard = watchLineLimit(input, maximumInputBytes, (error) => {
368
+ const measuredBytes = "measuredBytes" in error && typeof error.measuredBytes === "number"
369
+ ? error.measuredBytes
370
+ : undefined;
371
+ const failure = streamCapacityError("HOST_FRAME_TOO_LARGE", {
372
+ boundary: "host.rpc_transport",
373
+ limitBytes: maximumInputBytes,
374
+ ...(measuredBytes === undefined ? {} : { measuredBytes })
375
+ });
376
+ failure.cause = error;
377
+ this.close(failure);
378
+ input.destroy(failure);
342
379
  });
343
380
  const lines = createInterface({ input });
344
381
  lines.once("close", removeGuard);
@@ -369,7 +406,10 @@ export class AdapterHostRpcClient {
369
406
  const params = message.params ?? {};
370
407
  const invocationId = requiredString(params.invocationId, "invocationId");
371
408
  const queue = this.#invocations.get(invocationId);
372
- const rpcError = isRecord(params.error) ? new Error(errorMessage(params.error)) : undefined;
409
+ const detail = isRecord(params.error) ? params.error : undefined;
410
+ const rpcError = detail
411
+ ? Object.assign(new Error(errorMessage(detail)), safeStreamErrorDetails(detail))
412
+ : undefined;
373
413
  queue?.close(rpcError);
374
414
  this.#invocations.delete(invocationId);
375
415
  return;
@@ -460,13 +500,19 @@ export class AdapterHostRpcClient {
460
500
  /** Await the invoke ACK first, then keep yielding this invocation's event notifications until done. */
461
501
  async *invokeFrames(input, environment = {}) {
462
502
  const { signal, executionEnvOverrides } = environment;
503
+ const streamLimits = resolveStreamLimitPolicy(environment.streamLimits);
463
504
  const invocationId = input.invocationId ?? randomUUID();
464
505
  const wireInput = { ...input, invocationId };
465
506
  if (signal?.aborted)
466
507
  throw abortError(signal);
467
508
  if (this.#invocations.has(invocationId))
468
509
  throw new Error("EXECUTION_IDENTITY_CONFLICT");
469
- const queue = new AsyncQueue();
510
+ const queue = new AsyncQueue({
511
+ itemMaxBytes: streamLimits.hostFrameMaxBytes,
512
+ maxBytes: streamLimits.rpcQueueMaxBytes,
513
+ maxItems: streamLimits.rpcQueueMaxItems,
514
+ boundary: "host.rpc_queue"
515
+ });
470
516
  let terminal = false;
471
517
  let accepted = false;
472
518
  this.#invocations.set(invocationId, queue);
@@ -477,7 +523,13 @@ export class AdapterHostRpcClient {
477
523
  };
478
524
  signal?.addEventListener("abort", onAbort, { once: true });
479
525
  try {
480
- const receipt = await this.request(executionEnvOverrides?.env_variables.length ? "invoke.with-environment" : "invoke", { input: wireInput, ...(executionEnvOverrides ? { executionEnvOverrides } : {}) }, signal);
526
+ const receipt = await this.request(executionEnvOverrides?.env_variables.length || environment.streamLimits
527
+ ? "invoke.with-environment"
528
+ : "invoke", {
529
+ input: wireInput,
530
+ ...(executionEnvOverrides ? { executionEnvOverrides } : {}),
531
+ ...(environment.streamLimits ? { streamLimits } : {})
532
+ }, signal);
481
533
  assertHostRunReceipt(receipt);
482
534
  accepted = true;
483
535
  assertReceiptInput(receipt, wireInput);
@@ -521,6 +573,21 @@ function asRpcMessage(value) {
521
573
  function isRecord(value) {
522
574
  return value !== null && typeof value === "object" && !Array.isArray(value);
523
575
  }
576
+ function safeStreamErrorDetails(value) {
577
+ if (!isRecord(value))
578
+ return {};
579
+ const result = {};
580
+ if (typeof value.code === "string" && /^[A-Z][A-Z0-9_]{0,127}$/.test(value.code))
581
+ result.code = value.code;
582
+ if (typeof value.boundary === "string" && /^[a-z0-9][a-z0-9._-]{0,127}$/i.test(value.boundary))
583
+ result.boundary = value.boundary;
584
+ for (const key of ["measuredBytes", "limitBytes", "itemCount", "limitItems"]) {
585
+ const entry = value[key];
586
+ if (typeof entry === "number" && Number.isSafeInteger(entry) && entry >= 0)
587
+ result[key] = entry;
588
+ }
589
+ return result;
590
+ }
524
591
  function requiredString(value, name) {
525
592
  if (typeof value !== "string" || value.length === 0)
526
593
  throw new TypeError(`${name} must be a non-empty string`);
@@ -567,7 +634,12 @@ function probeOptions(value) {
567
634
  Array.isArray(options.providerOptions) ||
568
635
  Object.values(options.providerOptions).some((v) => typeof v !== "string")))
569
636
  throw new TypeError("invalid probe provider options");
570
- return options;
637
+ return {
638
+ ...options,
639
+ ...(options.streamLimits === undefined
640
+ ? {}
641
+ : { streamLimits: resolveStreamLimitPolicy(options.streamLimits) })
642
+ };
571
643
  }
572
644
  function probeConfigurations(value) {
573
645
  if (value === undefined)
@@ -1,5 +1,6 @@
1
1
  import { readFileSync, realpathSync } from "node:fs";
2
2
  import { isAbsolute, join, relative, resolve } from "node:path";
3
+ import { resolveStreamLimitPolicy } from "@mininglamp-oss/octo-runtime-protocol";
3
4
  export function readAdapterConfigurations(profileRoot, adaptersValue) {
4
5
  const adapters = objectValue(adaptersValue);
5
6
  const connections = { openclaw: { providerOptions: { OPENCLAW_RUNTIME_ROOT: profileRoot } } };
@@ -28,12 +29,42 @@ export function readAdapterConfigurations(profileRoot, adaptersValue) {
28
29
  return [
29
30
  adapterType,
30
31
  {
31
- providerOptions: { ...publicOptions, ...credentialOptions }
32
+ providerOptions: { ...publicOptions, ...credentialOptions },
33
+ ...(execution.stream_limits === undefined
34
+ ? {}
35
+ : { streamLimits: readStreamLimits(execution.stream_limits, adapterType) })
32
36
  }
33
37
  ];
34
38
  }))
35
39
  };
36
40
  }
41
+ const STREAM_LIMIT_FIELDS = {
42
+ raw_message_max_bytes: "rawMessageMaxBytes",
43
+ adapter_queue_item_max_bytes: "adapterQueueItemMaxBytes",
44
+ adapter_queue_max_bytes: "adapterQueueMaxBytes",
45
+ adapter_queue_max_items: "adapterQueueMaxItems",
46
+ host_frame_max_bytes: "hostFrameMaxBytes",
47
+ rpc_queue_max_bytes: "rpcQueueMaxBytes",
48
+ rpc_queue_max_items: "rpcQueueMaxItems",
49
+ replay_run_max_bytes: "replayRunMaxBytes",
50
+ replay_run_max_items: "replayRunMaxItems",
51
+ replay_global_max_bytes: "replayGlobalMaxBytes"
52
+ };
53
+ function readStreamLimits(value, adapterType) {
54
+ const record = objectValue(value);
55
+ if (!record)
56
+ throw new TypeError(`managed ${adapterType} stream_limits must be an object`);
57
+ const overrides = {};
58
+ for (const [key, entry] of Object.entries(record)) {
59
+ const field = STREAM_LIMIT_FIELDS[key];
60
+ if (!field)
61
+ throw new TypeError(`managed ${adapterType} stream_limits.${key} is unknown`);
62
+ if (!Number.isSafeInteger(entry) || entry < 1)
63
+ throw new TypeError(`managed ${adapterType} stream_limits.${key} must be a positive integer`);
64
+ overrides[field] = entry;
65
+ }
66
+ return { ...resolveStreamLimitPolicy(overrides) };
67
+ }
37
68
  function readCredentialOptions(profileRoot, credentialRef, adapterType) {
38
69
  const credentialsRoot = realpathSync(join(profileRoot, "credentials"));
39
70
  const credentialPath = realpathSync(resolve(profileRoot, credentialRef));
@@ -40,6 +40,11 @@ export async function startHostSocketServer(options) {
40
40
  }
41
41
  : request;
42
42
  };
43
+ const configuredStreamLimits = (request) => {
44
+ const adapterType = contextItem(request.contexts, "octo.execution", "adapter")?.payload.type;
45
+ const type = typeof adapterType === "string" ? adapterType : "codex";
46
+ return options.configurations?.(typeof request.runMetadata?.runtimeId === "string" ? request.runMetadata.runtimeId : undefined)?.[type]?.streamLimits;
47
+ };
43
48
  const transport = {
44
49
  list: (configs) => processHost.client.list(configs ?? options.configurations?.()),
45
50
  probe: (type, config) => processHost.client.probe(type, config ?? options.configurations?.()?.[type]),
@@ -49,7 +54,7 @@ export async function startHostSocketServer(options) {
49
54
  invoke: createInputInvoke((input, environment) => transport.invokeFrames(input, environment)),
50
55
  invokeFrames: (input, environment) => processHost.client.invokeFrames(configure(input), environment)
51
56
  };
52
- const host = new HostRunService(transport);
57
+ const host = new HostRunService(transport, configuredStreamLimits);
53
58
  const connections = new Set();
54
59
  let closing = false;
55
60
  const server = net.createServer((socket) => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-host",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -14,21 +14,21 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@mininglamp-oss/octo-runtime-core": "1.0.0",
18
- "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.0.0",
19
- "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.0.0",
20
- "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.0.0",
21
- "@mininglamp-oss/octo-runtime-adapter-codex": "1.0.0",
22
- "@mininglamp-oss/octo-runtime-adapter-hermes": "1.0.0",
23
- "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.0.0",
24
- "@mininglamp-oss/octo-runtime-adapter-mcode": "1.0.0",
25
- "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.0.0",
26
- "@mininglamp-oss/octo-runtime-adapter-opencode": "1.0.0",
27
- "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.0.0",
28
- "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.0.0",
29
- "@mininglamp-oss/octo-runtime-adapter-zcode-gui": "1.0.0",
30
- "@mininglamp-oss/octo-runtime-protocol": "1.0.0",
31
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.0.0"
17
+ "@mininglamp-oss/octo-runtime-core": "1.0.1",
18
+ "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.0.1",
19
+ "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.0.1",
20
+ "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.0.1",
21
+ "@mininglamp-oss/octo-runtime-adapter-codex": "1.0.1",
22
+ "@mininglamp-oss/octo-runtime-adapter-hermes": "1.0.1",
23
+ "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.0.1",
24
+ "@mininglamp-oss/octo-runtime-adapter-mcode": "1.0.1",
25
+ "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.0.1",
26
+ "@mininglamp-oss/octo-runtime-adapter-opencode": "1.0.1",
27
+ "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.0.1",
28
+ "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.0.1",
29
+ "@mininglamp-oss/octo-runtime-adapter-zcode-gui": "1.0.1",
30
+ "@mininglamp-oss/octo-runtime-protocol": "1.0.1",
31
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.0.1"
32
32
  },
33
33
  "types": "./dist/index.d.ts",
34
34
  "files": [
@@ -6,6 +6,6 @@ export declare const kimiCodeAdapter: Readonly<{
6
6
  };
7
7
  probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
8
8
  respondInteraction(invocationId: string, response: import("@mininglamp-oss/octo-runtime-protocol").InteractionResponse): Promise<void>;
9
- invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest): AsyncGenerator<import("@mininglamp-oss/octo-runtime-protocol").CanonicalEvent>;
9
+ invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context?: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext): AsyncGenerator<import("@mininglamp-oss/octo-runtime-protocol").CanonicalEvent>;
10
10
  }>;
11
11
  export default kimiCodeAdapter;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-kimi-code",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,6 +9,6 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.0"
12
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.1"
13
13
  }
14
14
  }
@@ -18,6 +18,6 @@ export declare const mcodeAdapter: Readonly<{
18
18
  };
19
19
  probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
20
20
  respondInteraction(invocationId: string, response: import("@mininglamp-oss/octo-runtime-protocol").InteractionResponse): Promise<void>;
21
- invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest): AsyncGenerator<import("@mininglamp-oss/octo-runtime-protocol").CanonicalEvent>;
21
+ invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context?: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext): AsyncGenerator<import("@mininglamp-oss/octo-runtime-protocol").CanonicalEvent>;
22
22
  }>;
23
23
  export default mcodeAdapter;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-mcode",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,6 +9,6 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.0"
12
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.1"
13
13
  }
14
14
  }
@@ -494,6 +494,8 @@ async function* invokeOpenClawGateway(req, invocation, context, clientFactory, p
494
494
  permissions.bindTransport(() => stop(!terminal));
495
495
  const queue = new DriverQueue({
496
496
  discardOnFailure: true,
497
+ limits: context?.streamLimits,
498
+ boundary: "openclaw.event_queue",
497
499
  onFailure: () => {
498
500
  resourceFailure = true;
499
501
  void stop(true);
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-openclaw",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
7
7
  "dependencies": {
8
- "@mininglamp-oss/octo-runtime-protocol": "1.0.0",
9
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.0.0",
10
- "ws": "8.21.3"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.0.1",
9
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.0.1",
10
+ "ws": "8.22.0"
11
11
  },
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [
@@ -321,7 +321,7 @@ export function createOpenCodeAdapter({ command = "opencode" } = {}) {
321
321
  if (request.approvalMode === "assisted")
322
322
  throw new Error("APPROVAL_MODE_UNSUPPORTED: opencode has no qualified assisted policy");
323
323
  if (request.approvalMode === "ask") {
324
- yield* interactive.invoke(request);
324
+ yield* interactive.invoke(request, context);
325
325
  return;
326
326
  }
327
327
  const normalizer = new OpenCodeEventNormalizer();
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-opencode",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
7
7
  "dependencies": {
8
- "@mininglamp-oss/octo-runtime-protocol": "1.0.0",
9
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.0",
10
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.0.0"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.0.1",
9
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.1",
10
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.0.1"
11
11
  },
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [
@@ -18,6 +18,6 @@ export declare const qoderCliAdapter: Readonly<{
18
18
  };
19
19
  probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
20
20
  respondInteraction(invocationId: string, response: import("@mininglamp-oss/octo-runtime-protocol").InteractionResponse): Promise<void>;
21
- invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest): AsyncGenerator<import("@mininglamp-oss/octo-runtime-protocol").CanonicalEvent>;
21
+ invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context?: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext): AsyncGenerator<import("@mininglamp-oss/octo-runtime-protocol").CanonicalEvent>;
22
22
  }>;
23
23
  export default qoderCliAdapter;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-qodercli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,6 +9,6 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.0"
12
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.1"
13
13
  }
14
14
  }
@@ -18,6 +18,6 @@ export declare const qoderCliCnAdapter: Readonly<{
18
18
  };
19
19
  probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
20
20
  respondInteraction(invocationId: string, response: import("@mininglamp-oss/octo-runtime-protocol").InteractionResponse): Promise<void>;
21
- invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest): AsyncGenerator<import("@mininglamp-oss/octo-runtime-protocol").CanonicalEvent>;
21
+ invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context?: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext): AsyncGenerator<import("@mininglamp-oss/octo-runtime-protocol").CanonicalEvent>;
22
22
  }>;
23
23
  export default qoderCliCnAdapter;