@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
@@ -1,3 +1,3 @@
1
- <!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Octo Runtime</title> <script type="module" crossorigin src="/assets/index-B6Yp4xkI.js"></script>
1
+ <!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Octo Runtime</title> <script type="module" crossorigin src="/assets/index-DiPc-ipL.js"></script>
2
2
  <link rel="stylesheet" crossorigin href="/assets/index-CYTpqItx.css">
3
3
  </head><body><div id="root"></div></body></html>
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-extra-webui",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "Local Runtime workbench with canonical SSE presentation",
@@ -19,6 +19,6 @@
19
19
  "porting-map.md"
20
20
  ],
21
21
  "dependencies": {
22
- "@mininglamp-oss/octo-runtime-protocol": "1.0.0"
22
+ "@mininglamp-oss/octo-runtime-protocol": "1.0.1"
23
23
  }
24
24
  }
@@ -31,6 +31,7 @@ export declare const FAILURE_CATALOG: Readonly<{
31
31
  "OH-RUN-2004": CatalogEntry;
32
32
  "OH-RUN-2005": CatalogEntry;
33
33
  "OH-RUN-2008": CatalogEntry;
34
+ "OH-RUN-2009": CatalogEntry;
34
35
  "OH-ADP-3002": CatalogEntry;
35
36
  "OH-ADP-3003": CatalogEntry;
36
37
  "OH-ADP-3004": CatalogEntry;
@@ -43,6 +44,7 @@ export declare const FAILURE_CATALOG: Readonly<{
43
44
  "OH-ADP-3011": CatalogEntry;
44
45
  "OH-ADP-3012": CatalogEntry;
45
46
  "OH-ADP-3013": CatalogEntry;
47
+ "OH-ADP-3014": CatalogEntry;
46
48
  "OH-PRV-4001": CatalogEntry;
47
49
  "OH-PRV-4002": CatalogEntry;
48
50
  "OH-PRV-4003": CatalogEntry;
@@ -51,6 +53,7 @@ export declare const FAILURE_CATALOG: Readonly<{
51
53
  "OH-PRV-4006": CatalogEntry;
52
54
  "OH-PRV-4007": CatalogEntry;
53
55
  "OH-PRV-4008": CatalogEntry;
56
+ "OH-PRV-4009": CatalogEntry;
54
57
  "OH-PRV-4099": CatalogEntry;
55
58
  "OH-SYS-9001": CatalogEntry;
56
59
  }>;
@@ -64,6 +67,7 @@ export declare function classifyFailure(input: unknown, context: FailureClassifi
64
67
  export declare function failurePayload(input: unknown, context: FailureClassificationContext): Record<string, unknown> & {
65
68
  failure: FailureEnvelope;
66
69
  };
70
+ export declare function safeCapacityEvidence(value: unknown): Record<string, string | number>;
67
71
  export declare function failureMessage(code: string): string;
68
72
  export declare function isFailureEnvelope(value: unknown): value is FailureEnvelope;
69
73
  export {};
@@ -11,6 +11,7 @@ export const FAILURE_CATALOG = Object.freeze({
11
11
  "OH-RUN-2004": entry("session_queue_capacity", "当前会话的排队任务已满,请稍后重试。", "error.runtime.session_queue_capacity", true, "retry_later", 30_000),
12
12
  "OH-RUN-2005": entry("channel_delivery_unknown", "回复已尝试发送,但未收到消息服务的确认,可能已送达。请先检查聊天记录,避免重复提交任务。", "error.channel.delivery_unknown", false, "contact_admin"),
13
13
  "OH-RUN-2008": entry("runtime_local_store", "运行设备存储异常,本轮任务已安全结束。", "error.runtime.local_store", true, "check_runtime"),
14
+ "OH-RUN-2009": entry("runtime_stream_capacity", "运行输出队列超过容量限制,本轮任务已停止。请检查运行设备的输出容量配置。", "error.runtime.stream_queue_capacity", false, "check_runtime"),
14
15
  "OH-ADP-3002": entry("adapter_dependency", "未找到 Agent 命令或必要程序。", "error.adapter.command_not_found", false, "install_dependency"),
15
16
  "OH-ADP-3003": entry("adapter_permission", "Agent 进程没有访问所需资源的权限。", "error.adapter.permission_denied", false, "fix_permissions"),
16
17
  "OH-ADP-3004": entry("adapter_invocation", "Agent 适配器启动或执行失败。", "error.adapter.invocation_failed", false, "contact_admin"),
@@ -23,6 +24,7 @@ export const FAILURE_CATALOG = Object.freeze({
23
24
  "OH-ADP-3011": entry("adapter_run_deadline", "任务已达到总运行时限。", "error.adapter.run_deadline", true, "retry"),
24
25
  "OH-ADP-3012": entry("adapter_cleanup_timeout", "Agent 结束清理超时,请检查运行环境。", "error.adapter.cleanup_timeout", false, "check_runtime"),
25
26
  "OH-ADP-3013": entry("adapter_rpc_timeout", "Agent 协议请求响应超时。", "error.adapter.rpc_timeout", true, "check_runtime"),
27
+ "OH-ADP-3014": entry("adapter_frame_capacity", "Agent 输出帧超过运行时容量限制,本轮任务已停止。", "error.adapter.host_frame_too_large", false, "check_runtime"),
26
28
  "OH-PRV-4001": entry("provider_authentication", "模型服务凭据无效或已失效。", "error.provider.credentials_invalid", false, "update_credentials"),
27
29
  "OH-PRV-4002": entry("provider_authorization", "当前账号无权使用所选模型或组织。", "error.provider.permission_denied", false, "contact_admin"),
28
30
  "OH-PRV-4003": entry("provider_model", "所选模型不存在或当前不可用。", "error.provider.model_not_found", false, "change_model"),
@@ -31,6 +33,7 @@ export const FAILURE_CATALOG = Object.freeze({
31
33
  "OH-PRV-4006": entry("provider_availability", "模型服务暂时不可用。", "error.provider.unavailable", true, "retry_later", 30_000),
32
34
  "OH-PRV-4007": entry("provider_client_policy", "当前授权方式不允许此客户端调用。", "error.provider.client_not_allowed", false, "update_credentials"),
33
35
  "OH-PRV-4008": entry("provider_configuration", "此 Agent 绑定的 Provider 配置已被删除或不可用。", "error.provider.configuration_missing", false, "change_model"),
36
+ "OH-PRV-4009": entry("provider_message_capacity", "模型服务返回的单条消息超过运行时容量限制,本轮任务已停止。", "error.provider.message_too_large", false, "check_runtime"),
34
37
  "OH-PRV-4099": entry("provider_unknown", "模型服务调用失败,暂时无法识别具体原因。", "error.provider.unknown", true, "retry"),
35
38
  "OH-SYS-9001": entry("system_unknown", "系统发生未知错误。", "error.system.unknown", true, "retry")
36
39
  });
@@ -94,7 +97,7 @@ export function failurePayload(input, context) {
94
97
  ].includes(reason)
95
98
  ? reason
96
99
  : undefined;
97
- const failure = timeoutStage || timeoutMs !== undefined
100
+ const baseFailure = timeoutStage || timeoutMs !== undefined
98
101
  ? {
99
102
  ...classified,
100
103
  params: {
@@ -106,6 +109,10 @@ export function failurePayload(input, context) {
106
109
  }
107
110
  }
108
111
  : classified;
112
+ const capacity = safeCapacityEvidence(record);
113
+ const failure = Object.keys(capacity).length > 0
114
+ ? { ...baseFailure, params: { ...baseFailure.params, ...capacity } }
115
+ : baseFailure;
109
116
  const adapterType = safeAdapterType(record.adapterType) ?? failure.source.adapter;
110
117
  const legacyCode = safeReasonCode(record.code) ?? failure.reasonCode;
111
118
  return {
@@ -167,6 +174,18 @@ function safeWatchdogEvidence(value) {
167
174
  result.activitySupport = input.activitySupport;
168
175
  return result;
169
176
  }
177
+ export function safeCapacityEvidence(value) {
178
+ const input = asRecord(value) ?? {};
179
+ const result = {};
180
+ if (typeof input.boundary === "string" && /^[a-z0-9][a-z0-9._-]{0,127}$/i.test(input.boundary))
181
+ result.boundary = input.boundary;
182
+ for (const key of ["measuredBytes", "limitBytes", "itemCount", "limitItems"]) {
183
+ const entry = input[key];
184
+ if (typeof entry === "number" && Number.isSafeInteger(entry) && entry >= 0)
185
+ result[key] = entry;
186
+ }
187
+ return result;
188
+ }
170
189
  function safeTimeoutMs(value) {
171
190
  return typeof value === "number" &&
172
191
  Number.isSafeInteger(value) &&
@@ -295,6 +314,16 @@ function classify(evidence, defaultDomain) {
295
314
  };
296
315
  if (explicit && timeouts[explicit])
297
316
  return result(timeouts[explicit], explicit);
317
+ if (explicit === "PROVIDER_MESSAGE_TOO_LARGE")
318
+ return result("OH-PRV-4009", "PROVIDER_MESSAGE_TOO_LARGE");
319
+ if (explicit === "HOST_FRAME_TOO_LARGE")
320
+ return result("OH-ADP-3014", "HOST_FRAME_TOO_LARGE");
321
+ if ([
322
+ "STREAM_QUEUE_ITEM_TOO_LARGE",
323
+ "STREAM_QUEUE_BYTES_EXCEEDED",
324
+ "STREAM_QUEUE_ITEMS_EXCEEDED"
325
+ ].includes(explicit ?? ""))
326
+ return result("OH-RUN-2009", explicit);
298
327
  if (explicit === "RUNTIME_DRAINING")
299
328
  return result("OH-RUN-2002", "RUNTIME_DRAINING");
300
329
  if (explicit === "IM_SESSION_QUEUE_FULL")
@@ -6,7 +6,7 @@
6
6
  * This interface was referenced by `OctoRuntimeProtocolSchema`'s JSON-Schema
7
7
  * via the `definition` "RunProtocolErrorCode".
8
8
  */
9
- export type RunProtocolErrorCode = "PROTOCOL_MODE_INVALID" | "PROTOCOL_MODE_UNSUPPORTED" | "EXECUTION_PROTOCOL_MISMATCH" | "EXECUTION_IDENTITY_CONFLICT" | "NATIVE_METHOD_UNSUPPORTED" | "NATIVE_RESPONSE_INVALID" | "INTERACTION_NOT_ACTIVE" | "HOST_EXECUTION_FAILED" | "HOST_ENDED_WITHOUT_TERMINAL" | "STREAM_GAP" | "STREAM_EXPIRED" | "REMOTE_NATIVE_UNSUPPORTED" | "HOST_FRAME_INVALID" | "HOST_CONTROL_INVALID" | "HOST_RECEIPT_INVALID" | "PROTOCOL_SUPPORT_INVALID";
9
+ export type RunProtocolErrorCode = "PROTOCOL_MODE_INVALID" | "PROTOCOL_MODE_UNSUPPORTED" | "EXECUTION_PROTOCOL_MISMATCH" | "EXECUTION_IDENTITY_CONFLICT" | "NATIVE_METHOD_UNSUPPORTED" | "NATIVE_RESPONSE_INVALID" | "INTERACTION_NOT_ACTIVE" | "HOST_EXECUTION_FAILED" | "HOST_ENDED_WITHOUT_TERMINAL" | "PROVIDER_MESSAGE_TOO_LARGE" | "HOST_FRAME_TOO_LARGE" | "STREAM_QUEUE_ITEM_TOO_LARGE" | "STREAM_QUEUE_BYTES_EXCEEDED" | "STREAM_QUEUE_ITEMS_EXCEEDED" | "STREAM_GAP" | "STREAM_EXPIRED" | "REMOTE_NATIVE_UNSUPPORTED" | "HOST_FRAME_INVALID" | "HOST_CONTROL_INVALID" | "HOST_RECEIPT_INVALID" | "PROTOCOL_SUPPORT_INVALID";
10
10
  /**
11
11
  * This interface was referenced by `OctoRuntimeProtocolSchema`'s JSON-Schema
12
12
  * via the `definition` "ProtocolMode".
@@ -48,6 +48,7 @@ export type HostControl = {
48
48
  type: "error";
49
49
  code: RunProtocolErrorCode;
50
50
  message: string;
51
+ failure?: FailureEnvelope;
51
52
  } | {
52
53
  type: "interaction";
53
54
  requestId: string | number;
@@ -1,5 +1,6 @@
1
1
  export { assertJsonByteLimit } from "./json-size.js";
2
2
  export { INVOKE_REQUEST_MAX_BYTES, assertInvokeRequestSize } from "./invoke-size.js";
3
+ export * from "./stream-limits.js";
3
4
  export * from "./run-protocol.js";
4
5
  export * from "./invoke-input.js";
5
6
  export * from "./model-context.js";
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  export { assertJsonByteLimit } from "./json-size.js";
3
3
  export { INVOKE_REQUEST_MAX_BYTES, assertInvokeRequestSize } from "./invoke-size.js";
4
+ export * from "./stream-limits.js";
4
5
  export * from "./run-protocol.js";
5
6
  export * from "./invoke-input.js";
6
7
  export * from "./model-context.js";
@@ -1,4 +1,5 @@
1
1
  import { type AgentConfig, type AgentSource, type ApprovalMode, type CanonicalEvent, type ContextEnvelope, type ContextEnvsPayload, type HostFrame, type InvokeRequest, type ModelInputPart, type ProviderSession, type RuntimeLimits } from "./index.js";
2
+ import type { StreamLimitPolicy } from "./stream-limits.js";
2
3
  /**
3
4
  * Public JSON invocation contract shared by CLI, SDK and channels.
4
5
  * A plain JSON object satisfies this class structurally; `new` is not required.
@@ -58,6 +59,8 @@ export interface InvokeEnvironment {
58
59
  signal?: AbortSignal;
59
60
  /** Trusted per-invocation values; forwarded privately across the Host process boundary. */
60
61
  executionEnvOverrides?: ContextEnvsPayload;
62
+ /** Trusted transport and replay budgets; never sourced from caller Context. */
63
+ streamLimits?: StreamLimitPolicy;
61
64
  }
62
65
  export type InputFrames = (input: InvokeInput, environment?: InvokeEnvironment) => AsyncGenerator<HostFrame>;
63
66
  /** Stable correlation IDs for cancellation and stream reconnection, without resolving execution. */
@@ -5,6 +5,7 @@ export function assertInvokeRequestSize(input, environment = {}) {
5
5
  input: { ...input },
6
6
  ...(environment.executionEnvOverrides
7
7
  ? { executionEnvOverrides: environment.executionEnvOverrides }
8
- : {})
8
+ : {}),
9
+ ...(environment.streamLimits ? { streamLimits: environment.streamLimits } : {})
9
10
  }, INVOKE_REQUEST_MAX_BYTES, "INVOKE_REQUEST_TOO_LARGE");
10
11
  }
@@ -1,7 +1,7 @@
1
1
  import { type CanonicalEvent } from "./index.js";
2
2
  import type { ProtocolMode, RunProtocolErrorCode, HostInvokeOptions, HostRunReceipt, HostFrame, NativeHostFrame, CanonicalHostFrame, ControlHostFrame, HostControl, NativeInteractionResponse, AdapterProtocolSupport } from "./generated/protocol-types.js";
3
3
  export type { ProtocolMode, RunProtocolErrorCode, HostInvokeOptions, HostRunReceipt, HostFrame, NativeHostFrame, CanonicalHostFrame, ControlHostFrame, HostControl, NativeInteractionResponse, AdapterProtocolSupport };
4
- export declare const RUN_PROTOCOL_ERRORS: readonly ["PROTOCOL_MODE_INVALID", "PROTOCOL_MODE_UNSUPPORTED", "EXECUTION_PROTOCOL_MISMATCH", "EXECUTION_IDENTITY_CONFLICT", "NATIVE_METHOD_UNSUPPORTED", "NATIVE_RESPONSE_INVALID", "INTERACTION_NOT_ACTIVE", "HOST_EXECUTION_FAILED", "HOST_ENDED_WITHOUT_TERMINAL", "STREAM_GAP", "STREAM_EXPIRED", "REMOTE_NATIVE_UNSUPPORTED", "HOST_FRAME_INVALID", "HOST_CONTROL_INVALID", "HOST_RECEIPT_INVALID", "PROTOCOL_SUPPORT_INVALID"];
4
+ export declare const RUN_PROTOCOL_ERRORS: readonly ["PROTOCOL_MODE_INVALID", "PROTOCOL_MODE_UNSUPPORTED", "EXECUTION_PROTOCOL_MISMATCH", "EXECUTION_IDENTITY_CONFLICT", "NATIVE_METHOD_UNSUPPORTED", "NATIVE_RESPONSE_INVALID", "INTERACTION_NOT_ACTIVE", "HOST_EXECUTION_FAILED", "HOST_ENDED_WITHOUT_TERMINAL", "PROVIDER_MESSAGE_TOO_LARGE", "HOST_FRAME_TOO_LARGE", "STREAM_QUEUE_ITEM_TOO_LARGE", "STREAM_QUEUE_BYTES_EXCEEDED", "STREAM_QUEUE_ITEMS_EXCEEDED", "STREAM_GAP", "STREAM_EXPIRED", "REMOTE_NATIVE_UNSUPPORTED", "HOST_FRAME_INVALID", "HOST_CONTROL_INVALID", "HOST_RECEIPT_INVALID", "PROTOCOL_SUPPORT_INVALID"];
5
5
  export declare function protocolError(code: (typeof RUN_PROTOCOL_ERRORS)[number], message?: string): Error & {
6
6
  code: (typeof RUN_PROTOCOL_ERRORS)[number];
7
7
  };
@@ -1,6 +1,8 @@
1
1
  import { assertJsonValue } from "./context.js";
2
2
  import { assertExecutionEvidence } from "./actmode.js";
3
- import { assertCanonicalEvent } from "./index.js";
3
+ import { assertCanonicalEvent, assertFailureEnvelope } from "./index.js";
4
+ import { safeCapacityEvidence } from "./failure.js";
5
+ import { isStreamCapacityReason } from "./stream-limits.js";
4
6
  export const RUN_PROTOCOL_ERRORS = [
5
7
  "PROTOCOL_MODE_INVALID",
6
8
  "PROTOCOL_MODE_UNSUPPORTED",
@@ -11,6 +13,11 @@ export const RUN_PROTOCOL_ERRORS = [
11
13
  "INTERACTION_NOT_ACTIVE",
12
14
  "HOST_EXECUTION_FAILED",
13
15
  "HOST_ENDED_WITHOUT_TERMINAL",
16
+ "PROVIDER_MESSAGE_TOO_LARGE",
17
+ "HOST_FRAME_TOO_LARGE",
18
+ "STREAM_QUEUE_ITEM_TOO_LARGE",
19
+ "STREAM_QUEUE_BYTES_EXCEEDED",
20
+ "STREAM_QUEUE_ITEMS_EXCEEDED",
14
21
  "STREAM_GAP",
15
22
  "STREAM_EXPIRED",
16
23
  "REMOTE_NATIVE_UNSUPPORTED",
@@ -110,10 +117,42 @@ export function assertHostControl(value) {
110
117
  ["running", "completed", "failed", "cancelled", "lost"].includes(String(value.state)))
111
118
  return;
112
119
  if (value.type === "error" &&
113
- exactKeys(value, ["type", "code", "message"]) &&
120
+ exactKeys(value, ["type", "code", "message"], ["failure"]) &&
114
121
  RUN_PROTOCOL_ERRORS.some((code) => code === value.code) &&
115
- typeof value.message === "string")
122
+ typeof value.message === "string") {
123
+ if (Object.hasOwn(value, "failure")) {
124
+ try {
125
+ assertFailureEnvelope(value.failure);
126
+ const evidence = safeCapacityEvidence(value.failure.params);
127
+ if (!isStreamCapacityReason(value.code) ||
128
+ value.failure.reasonCode !== value.code ||
129
+ !exactKeys(value.failure, [
130
+ "schemaVersion",
131
+ "code",
132
+ "reasonCode",
133
+ "category",
134
+ "stage",
135
+ "messageKey",
136
+ "params",
137
+ "retryable",
138
+ "action",
139
+ "diagnosticId",
140
+ "source",
141
+ "occurredAt"
142
+ ], ["retryAfterMs", "cause"]) ||
143
+ !exactKeys(value.failure.source, ["component"], ["adapter"]) ||
144
+ !exactKeys(value.failure.action, ["type", "labelKey"]) ||
145
+ (value.failure.cause !== undefined &&
146
+ !exactKeys(value.failure.cause, ["reasonCode"], ["httpStatus"])) ||
147
+ Object.entries(value.failure.params).some(([key, entry]) => evidence[key] !== entry))
148
+ throw protocolError("HOST_CONTROL_INVALID");
149
+ }
150
+ catch {
151
+ throw protocolError("HOST_CONTROL_INVALID");
152
+ }
153
+ }
116
154
  return;
155
+ }
117
156
  if (value.type === "interaction" &&
118
157
  exactKeys(value, ["type", "requestId", "status"], ["expiresAt"]) &&
119
158
  requestId(value.requestId) &&
@@ -206,7 +245,15 @@ export async function* canonicalEvents(frames) {
206
245
  else if (frame.kind === "control" && frame.control.type === "gap")
207
246
  throw protocolError("STREAM_GAP");
208
247
  else if (frame.kind === "control" && frame.control.type === "error")
209
- throw Object.assign(new Error(frame.control.message), { code: frame.control.code });
248
+ throw Object.assign(new Error(frame.control.message), {
249
+ code: frame.control.code,
250
+ ...(frame.control.failure
251
+ ? {
252
+ ...safeCapacityEvidence(frame.control.failure.params),
253
+ failure: frame.control.failure
254
+ }
255
+ : {})
256
+ });
210
257
  }
211
258
  }
212
259
  function validIdentity(value) {
@@ -0,0 +1,27 @@
1
+ export interface StreamLimitPolicy {
2
+ rawMessageMaxBytes: number;
3
+ adapterQueueItemMaxBytes: number;
4
+ adapterQueueMaxBytes: number;
5
+ adapterQueueMaxItems: number;
6
+ hostFrameMaxBytes: number;
7
+ rpcQueueMaxBytes: number;
8
+ rpcQueueMaxItems: number;
9
+ replayRunMaxBytes: number;
10
+ replayRunMaxItems: number;
11
+ replayGlobalMaxBytes: number;
12
+ }
13
+ export type StreamLimitOverrides = Partial<StreamLimitPolicy>;
14
+ export declare const DEFAULT_STREAM_LIMIT_POLICY: Readonly<StreamLimitPolicy>;
15
+ export declare const MAX_STREAM_LIMIT_POLICY: Readonly<StreamLimitPolicy>;
16
+ export declare const HOST_RPC_MAX_LINE_BYTES: number;
17
+ export declare function resolveStreamLimitPolicy(overrides: StreamLimitOverrides | undefined): Readonly<StreamLimitPolicy>;
18
+ export declare const STREAM_CAPACITY_REASONS: readonly ["PROVIDER_MESSAGE_TOO_LARGE", "HOST_FRAME_TOO_LARGE", "STREAM_QUEUE_ITEM_TOO_LARGE", "STREAM_QUEUE_BYTES_EXCEEDED", "STREAM_QUEUE_ITEMS_EXCEEDED"];
19
+ export type StreamCapacityReason = (typeof STREAM_CAPACITY_REASONS)[number];
20
+ export declare function isStreamCapacityReason(value: unknown): value is StreamCapacityReason;
21
+ export declare function streamCapacityError(code: StreamCapacityReason, detail: {
22
+ boundary: string;
23
+ measuredBytes?: number;
24
+ limitBytes?: number;
25
+ itemCount?: number;
26
+ limitItems?: number;
27
+ }): Error;
@@ -0,0 +1,56 @@
1
+ const MIB = 1024 * 1024;
2
+ export const DEFAULT_STREAM_LIMIT_POLICY = Object.freeze({
3
+ rawMessageMaxBytes: 16 * MIB,
4
+ adapterQueueItemMaxBytes: 20 * MIB,
5
+ adapterQueueMaxBytes: 32 * MIB,
6
+ adapterQueueMaxItems: 4096,
7
+ hostFrameMaxBytes: 20 * MIB,
8
+ rpcQueueMaxBytes: 32 * MIB,
9
+ rpcQueueMaxItems: 4096,
10
+ replayRunMaxBytes: 32 * MIB,
11
+ replayRunMaxItems: 4096,
12
+ replayGlobalMaxBytes: 128 * MIB
13
+ });
14
+ export const MAX_STREAM_LIMIT_POLICY = Object.freeze(Object.fromEntries(Object.entries(DEFAULT_STREAM_LIMIT_POLICY).map(([key, value]) => [key, value * 2])));
15
+ export const HOST_RPC_MAX_LINE_BYTES = MAX_STREAM_LIMIT_POLICY.hostFrameMaxBytes + 64 * 1024;
16
+ export function resolveStreamLimitPolicy(overrides) {
17
+ if (overrides !== undefined &&
18
+ (overrides === null || typeof overrides !== "object" || Array.isArray(overrides)))
19
+ throw new TypeError("stream_limits must be an object");
20
+ const fields = new Set(Object.keys(DEFAULT_STREAM_LIMIT_POLICY));
21
+ for (const key of Object.keys(overrides ?? {})) {
22
+ if (!fields.has(key))
23
+ throw new TypeError(`unknown stream_limits.${key}`);
24
+ }
25
+ const policy = { ...DEFAULT_STREAM_LIMIT_POLICY, ...(overrides ?? {}) };
26
+ for (const key of Object.keys(DEFAULT_STREAM_LIMIT_POLICY)) {
27
+ const value = policy[key];
28
+ if (!Number.isSafeInteger(value) || value < 1 || value > MAX_STREAM_LIMIT_POLICY[key]) {
29
+ throw new TypeError(`invalid stream_limits.${key}`);
30
+ }
31
+ }
32
+ if (policy.rawMessageMaxBytes > policy.adapterQueueItemMaxBytes)
33
+ throw new TypeError("stream_limits.rawMessageMaxBytes exceeds adapterQueueItemMaxBytes");
34
+ if (policy.adapterQueueItemMaxBytes > policy.adapterQueueMaxBytes)
35
+ throw new TypeError("stream_limits.adapterQueueItemMaxBytes exceeds adapterQueueMaxBytes");
36
+ if (policy.hostFrameMaxBytes > policy.rpcQueueMaxBytes)
37
+ throw new TypeError("stream_limits.hostFrameMaxBytes exceeds rpcQueueMaxBytes");
38
+ if (policy.hostFrameMaxBytes > policy.replayRunMaxBytes)
39
+ throw new TypeError("stream_limits.hostFrameMaxBytes exceeds replayRunMaxBytes");
40
+ if (policy.replayRunMaxBytes > policy.replayGlobalMaxBytes)
41
+ throw new TypeError("stream_limits.replayRunMaxBytes exceeds replayGlobalMaxBytes");
42
+ return Object.freeze(policy);
43
+ }
44
+ export const STREAM_CAPACITY_REASONS = [
45
+ "PROVIDER_MESSAGE_TOO_LARGE",
46
+ "HOST_FRAME_TOO_LARGE",
47
+ "STREAM_QUEUE_ITEM_TOO_LARGE",
48
+ "STREAM_QUEUE_BYTES_EXCEEDED",
49
+ "STREAM_QUEUE_ITEMS_EXCEEDED"
50
+ ];
51
+ export function isStreamCapacityReason(value) {
52
+ return STREAM_CAPACITY_REASONS.includes(value);
53
+ }
54
+ export function streamCapacityError(code, detail) {
55
+ return Object.assign(new Error(code), { code, ...detail });
56
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-protocol",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -75,11 +75,24 @@ class WebSocket extends EventEmitter {
75
75
  this._redirects = 0;
76
76
 
77
77
  if (protocols === undefined) {
78
- protocols = [];
78
+ if (!options || options.protocols === undefined) {
79
+ protocols = [];
80
+ } else if (Array.isArray(options.protocols)) {
81
+ protocols = options.protocols;
82
+ } else {
83
+ protocols = [options.protocols];
84
+ }
79
85
  } else if (!Array.isArray(protocols)) {
80
86
  if (typeof protocols === 'object' && protocols !== null) {
81
87
  options = protocols;
82
- protocols = [];
88
+
89
+ if (options.protocols === undefined) {
90
+ protocols = [];
91
+ } else if (Array.isArray(options.protocols)) {
92
+ protocols = options.protocols;
93
+ } else {
94
+ protocols = [options.protocols];
95
+ }
83
96
  } else {
84
97
  protocols = [protocols];
85
98
  }
@@ -318,7 +331,6 @@ class WebSocket extends EventEmitter {
318
331
  return;
319
332
  }
320
333
 
321
- this._readyState = WebSocket.CLOSING;
322
334
  this._sender.close(code, data, !this._isServer, (err) => {
323
335
  //
324
336
  // This error is handled by the `'error'` listener on the socket. We only
@@ -336,6 +348,7 @@ class WebSocket extends EventEmitter {
336
348
  }
337
349
  });
338
350
 
351
+ this._readyState = WebSocket.CLOSING;
339
352
  setCloseTimer(this);
340
353
  }
341
354
 
@@ -681,6 +694,7 @@ function initAsClient(websocket, address, protocols, options) {
681
694
  socketPath: undefined,
682
695
  hostname: undefined,
683
696
  protocol: undefined,
697
+ protocols: undefined,
684
698
  timeout: undefined,
685
699
  method: 'GET',
686
700
  host: undefined,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ws",
3
- "version": "8.21.3",
3
+ "version": "8.22.0",
4
4
  "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
5
5
  "keywords": [
6
6
  "HyBi",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Provider-neutral Agent runtime for unified execution through provider adapters",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,28 +43,28 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@mininglamp-oss/octo-runtime-extra-webui": "1.0.0",
47
- "@mininglamp-oss/octo-runtime-protocol": "1.0.0",
48
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.0",
49
- "@mininglamp-oss/octo-runtime-acp-client": "1.0.0",
50
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.0.0",
51
- "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.0.0",
52
- "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.0.0",
53
- "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.0.0",
54
- "@mininglamp-oss/octo-runtime-adapter-codex": "1.0.0",
55
- "@mininglamp-oss/octo-runtime-adapter-hermes": "1.0.0",
56
- "@mininglamp-oss/octo-runtime-adapter-host": "1.0.0",
57
- "@mininglamp-oss/octo-runtime-core": "1.0.0",
58
- "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.0.0",
59
- "@mininglamp-oss/octo-runtime-adapter-mcode": "1.0.0",
60
- "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.0.0",
61
- "ws": "8.21.3",
62
- "@mininglamp-oss/octo-runtime-adapter-opencode": "1.0.0",
63
- "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.0.0",
64
- "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.0.0",
65
- "@mininglamp-oss/octo-runtime-adapter-zcode-gui": "1.0.0",
66
- "@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.0.0",
67
- "@mininglamp-oss/octo-runtime-daemon": "1.0.0",
46
+ "@mininglamp-oss/octo-runtime-extra-webui": "1.0.1",
47
+ "@mininglamp-oss/octo-runtime-protocol": "1.0.1",
48
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.0.1",
49
+ "@mininglamp-oss/octo-runtime-acp-client": "1.0.1",
50
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.0.1",
51
+ "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.0.1",
52
+ "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.0.1",
53
+ "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.0.1",
54
+ "@mininglamp-oss/octo-runtime-adapter-codex": "1.0.1",
55
+ "@mininglamp-oss/octo-runtime-adapter-hermes": "1.0.1",
56
+ "@mininglamp-oss/octo-runtime-adapter-host": "1.0.1",
57
+ "@mininglamp-oss/octo-runtime-core": "1.0.1",
58
+ "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.0.1",
59
+ "@mininglamp-oss/octo-runtime-adapter-mcode": "1.0.1",
60
+ "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.0.1",
61
+ "ws": "8.22.0",
62
+ "@mininglamp-oss/octo-runtime-adapter-opencode": "1.0.1",
63
+ "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.0.1",
64
+ "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.0.1",
65
+ "@mininglamp-oss/octo-runtime-adapter-zcode-gui": "1.0.1",
66
+ "@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.0.1",
67
+ "@mininglamp-oss/octo-runtime-daemon": "1.0.1",
68
68
  "ajv": "8.20.0",
69
69
  "fast-deep-equal": "3.1.3",
70
70
  "fast-uri": "3.1.8",
@@ -106,10 +106,10 @@
106
106
  "micromark-util-sanitize-uri": "2.0.1",
107
107
  "micromark-util-decode-string": "2.0.1",
108
108
  "unist-util-stringify-position": "4.0.0",
109
- "@mininglamp-oss/octo-runtime-cross-service": "1.0.0",
110
- "@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.0.0",
111
- "@mininglamp-oss/octo-runtime-cli": "1.0.0",
112
- "@mininglamp-oss/octo-runtime-daemon-app": "1.0.0",
109
+ "@mininglamp-oss/octo-runtime-cross-service": "1.0.1",
110
+ "@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.0.1",
111
+ "@mininglamp-oss/octo-runtime-cli": "1.0.1",
112
+ "@mininglamp-oss/octo-runtime-daemon-app": "1.0.1",
113
113
  "json5": "2.2.3"
114
114
  },
115
115
  "bundleDependencies": [