@mininglamp-oss/octo-runtime 1.1.13 → 1.1.15

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 (96) hide show
  1. package/apps/cli/dist/adapters.js +1 -5
  2. package/apps/cli/dist/build-info.json +2 -2
  3. package/dist/public/protocol.d.ts +1 -1
  4. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  5. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +19 -4
  6. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +24 -29
  7. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  8. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +0 -1
  9. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  10. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.d.ts +3 -0
  11. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.js +10 -0
  12. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +23 -24
  13. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  14. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +1 -2
  15. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  16. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.d.ts +3 -0
  17. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.js +10 -0
  18. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +25 -30
  19. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +0 -2
  20. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  21. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-H3S6WM37.js → chunk-NGR74QLF.js} +0 -1
  22. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-SMTJTIN7.js → chunk-RIZUXNZ2.js} +115 -40
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-RISQ6NGV.js → chunk-XIUZ6GXG.js} +1 -1
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +0 -1
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +2 -6
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +9 -9
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.d.ts +5 -2
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +0 -2
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +8 -18
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.d.ts +3 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.js +10 -0
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +1 -12
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +16 -2
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +1 -2
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +16 -2
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +1 -2
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +16 -2
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +1 -2
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +0 -4
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +2 -3
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +6 -3
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +16 -2
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +1 -2
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -3
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +16 -2
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +1 -2
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -3
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +2 -3
  59. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +6 -28
  60. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +0 -2
  61. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +2 -7
  62. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  63. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +1 -5
  64. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  65. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +20 -20
  66. package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +2 -2
  67. package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +2 -2
  68. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +42 -624
  69. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  70. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +97 -12
  71. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.d.ts +21 -0
  72. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.js +189 -0
  73. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +0 -1
  74. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +3 -4
  75. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  76. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -5
  77. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  78. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +1 -1
  79. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +1 -5
  80. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +0 -3
  81. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +1 -26
  82. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.js +7 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +3 -12
  84. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +16 -240
  85. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -5
  86. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +2 -12
  87. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +0 -12
  88. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  89. package/package.json +24 -24
  90. package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -624
  91. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.d.ts +0 -5
  92. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.js +0 -8
  93. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.d.ts +0 -4
  94. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.js +0 -36
  95. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.d.ts +0 -3
  96. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.js +0 -68
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-cross-service",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "private": true,
5
5
  "description": "Native user-service lifecycle backends for Octo Runtime",
6
6
  "type": "module",
@@ -4,6 +4,7 @@ import { sanitizePublicValue, isAdapterPreparationFailure } from "@mininglamp-os
4
4
  export { prepareInvokeInput } from "./invoke-input.js";
5
5
  import { createInputInvoke, assertInvokeRequestSize, assertServiceProcessSnapshot, assertProtocolSupport, assertAdapterProtocolSupport, assertHostFrame, assertHostFrameIdentity, assertNativeInteractionResponse, resolveHostInvokeOptions, protocolError, assertCanonicalEvent, assertInteractionResponse, assertInvokeRequest, failurePayload, isCodexLocalFailure, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError, isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
6
6
  import { InvocationExperience } from "./experience.js";
7
+ import { ModelOutputSilence } from "./model-output-silence.js";
7
8
  import { noopRuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
8
9
  import { AdapterWatchdogTimeoutError, InvocationWatchdog } from "./watchdog.js";
9
10
  /**
@@ -576,6 +577,8 @@ export class AgentExecutor {
576
577
  session_id: request.agentSessionId,
577
578
  adapter_type: adapterType
578
579
  };
580
+ // 静默事实只属于 canonical;native 不实例化观察器、不新增控制帧。
581
+ const silence = protocolMode === "canonical" ? new ModelOutputSilence() : undefined;
579
582
  const watchdog = new InvocationWatchdog(undefined, controller, (diagnostic) => this.#log("warn", "invoke.watchdog", {
580
583
  ...identity,
581
584
  code: diagnostic.event
@@ -586,6 +589,7 @@ export class AgentExecutor {
586
589
  let cleanupWait;
587
590
  let cleanupDeadline;
588
591
  let completedBeforeCleanup = false;
592
+ let preparedNext;
589
593
  const beginCleanup = () => (cleanupDeadline ??= performance.now() + watchdog.limits.cancelGraceMs);
590
594
  const remainingCleanup = () => Math.max(0, beginCleanup() - performance.now());
591
595
  owner.close = async () => {
@@ -603,14 +607,49 @@ export class AgentExecutor {
603
607
  throw new Error("EXECUTOR_CLEANUP_UNVERIFIED");
604
608
  };
605
609
  const readNext = async (source) => {
610
+ let result;
606
611
  try {
607
- const result = await source.next();
608
- if (result.done)
612
+ result = await source.next();
613
+ }
614
+ catch (error) {
615
+ silence?.dispose();
616
+ if (!terminal && !nativeTerminal)
617
+ watchdog.terminal();
618
+ // 只有源 next 本身拒绝才使其 finally 清理存疑;校验错误不冒充清理失败。
619
+ nextFailed = !isAdapterPreparationFailure(error, context);
620
+ throw error;
621
+ }
622
+ try {
623
+ if (result.done) {
609
624
  iteratorDone = true;
625
+ silence?.dispose();
626
+ if (!terminal && !nativeTerminal)
627
+ watchdog.terminal();
628
+ }
629
+ else if (silence) {
630
+ // 在源结果就绪时刷新,避免消费者停在 notice 的 yield 时继续累计旧区间。
631
+ assertCanonicalEvent(result.value);
632
+ const event = result.value;
633
+ // notice 让 next 保持在途;背压期间到达的进展/等待/终态也必须立即生效,
634
+ // 不能由消费者恢复读取的时刻决定超时或让晚到取消覆盖已到达的终态。
635
+ watchdog.canonical(event);
636
+ if (isTerminal(event) && !controller.signal.aborted)
637
+ this.#acceptedTerminals.add(request.invocationId);
638
+ // 无身份的空占位/全局关闭补丁仍按原分支处理,不能凭空创建消息。
639
+ if (!(!event.payload.messageId &&
640
+ !event.payload.text &&
641
+ (event.type === "message.create" ||
642
+ (event.type === "message.update" &&
643
+ ["completed", "failed", "cancelled", "canceled", "stopped"].includes(String(event.payload.status))))))
644
+ preparedNext = prepareMessage(event);
645
+ silence.canonical(preparedNext?.event ?? event, preparedNext?.hasOutput ?? false);
646
+ }
610
647
  return result;
611
648
  }
612
649
  catch (error) {
613
- nextFailed = !isAdapterPreparationFailure(error, context);
650
+ silence?.dispose();
651
+ if (!terminal && !nativeTerminal)
652
+ watchdog.terminal();
614
653
  throw error;
615
654
  }
616
655
  };
@@ -621,6 +660,7 @@ export class AgentExecutor {
621
660
  const waitCleanup = () => (cleanupWait ??= boundedCleanup(closeIterator(), remainingCleanup()));
622
661
  // The timer can fire while a consumer is paused at yield.
623
662
  const onAbort = () => {
663
+ silence?.dispose();
624
664
  void waitCleanup().catch(() => undefined);
625
665
  };
626
666
  controller.signal.addEventListener("abort", onAbort, { once: true });
@@ -638,7 +678,10 @@ export class AgentExecutor {
638
678
  throw protocolError("EXECUTION_PROTOCOL_MISMATCH", "Native execution invoked a canonical converter");
639
679
  conversions++;
640
680
  },
641
- reportActivity: (activity) => watchdog.activity(activity),
681
+ reportActivity: (activity) => {
682
+ watchdog.activity(activity);
683
+ silence?.activity(activity);
684
+ },
642
685
  reportExecutionResult: (result) => {
643
686
  if (result.status === "completed" &&
644
687
  result.basis === "final_answer_cleanup_fallback" &&
@@ -652,7 +695,7 @@ export class AgentExecutor {
652
695
  event.type === "message.delta" ||
653
696
  event.type === "message.update";
654
697
  if (!isMessage)
655
- return { prefix: [], event };
698
+ return { prefix: [], event, hasOutput: false };
656
699
  const previous = event.payload.messageId ? messages.get(event.payload.messageId) : undefined;
657
700
  const channel = event.payload.channel ?? previous?.channel ?? "final";
658
701
  const segmentKey = `${channel}:${event.payload.stepId ?? ""}`;
@@ -696,14 +739,27 @@ export class AgentExecutor {
696
739
  : [];
697
740
  const closed = event.type === "message.update" &&
698
741
  ["completed", "failed", "cancelled", "canceled", "stopped"].includes(String(event.payload.status));
742
+ const role = event.payload.role ?? state?.role ?? "assistant";
743
+ const text = event.payload.text ?? "";
744
+ // 状态补丁、空快照及回退快照不能降低长度,否则旧快照会冒充新增输出。
745
+ const textLength = event.type === "message.delta"
746
+ ? (state?.textLength ?? 0) + text.length
747
+ : Math.max(state?.textLength ?? 0, text.length);
748
+ const hasOutput = role === "assistant" &&
749
+ (channel !== "analysis" ||
750
+ ["public_reasoning", "public_summary", "public_plan"].includes(prepared.payload.exposure ?? "")) &&
751
+ text.trim().length > 0 &&
752
+ (event.type === "message.delta" || textLength > (state?.textLength ?? 0));
699
753
  messages.set(messageId, {
700
754
  messageId,
701
755
  channel,
756
+ role,
757
+ textLength,
702
758
  open: !closed,
703
759
  ...(stepId ? { stepId } : {}),
704
760
  ...analysisMetadata
705
761
  });
706
- return { prefix, event: prepared };
762
+ return { prefix, event: prepared, hasOutput };
707
763
  };
708
764
  const closeMessages = (status, stepId, onlyAnonymous = false) => {
709
765
  const closed = [];
@@ -733,17 +789,31 @@ export class AgentExecutor {
733
789
  controller.signal.throwIfAborted();
734
790
  const invocation = adapter.invoke({ ...request, signal: controller.signal }, context);
735
791
  iterator = invocation[Symbol.asyncIterator]();
792
+ let pendingNext;
736
793
  while (true) {
737
794
  if (controller.signal.aborted)
738
795
  throw controller.signal.reason;
739
- const pendingNext = readNext(iterator);
796
+ // notice 不消费 Provider 结果;复用同一个 next,绝不并发拉取或丢弃结果。
797
+ pendingNext ??= readNext(iterator);
740
798
  const next = terminal || nativeTerminal
741
799
  ? await withCleanupDeadline(pendingNext, beginCleanup(), watchdog.limits.cancelGraceMs, controller)
742
- : await waitForNext(pendingNext, controller.signal);
800
+ : await waitForProviderOutput(pendingNext, controller.signal, silence);
801
+ if (controller.signal.aborted)
802
+ throw controller.signal.reason;
803
+ // 普通源结果和通知可以同时就绪;先交付已生成的事实,不依赖 race 的赢家。
804
+ // yield 期间源 next 仍保持唯一在途;恢复后再次核对取消,不消费已取消的结果。
805
+ const notice = silence?.take();
806
+ if (notice)
807
+ yield notice;
743
808
  if (controller.signal.aborted)
744
809
  throw controller.signal.reason;
810
+ if (next === "notice")
811
+ continue;
812
+ pendingNext = undefined;
745
813
  if (next.done)
746
814
  break;
815
+ const prepared = preparedNext;
816
+ preparedNext = undefined;
747
817
  const adapterEvent = next.value;
748
818
  if (protocolMode === "native") {
749
819
  if (!("kind" in adapterEvent))
@@ -777,7 +847,6 @@ export class AgentExecutor {
777
847
  })
778
848
  }
779
849
  : adapterEvent;
780
- watchdog.canonical(event);
781
850
  if (terminal)
782
851
  throw new Error(`${adapterType} emitted after terminal event`);
783
852
  if (isTerminal(event)) {
@@ -807,10 +876,10 @@ export class AgentExecutor {
807
876
  for (const closed of closeMessages(event.payload.status, event.payload.stepId))
808
877
  yield closed;
809
878
  }
810
- const prepared = prepareMessage(event);
811
- for (const prefix of prepared.prefix)
879
+ const output = prepared ?? prepareMessage(event);
880
+ for (const prefix of output.prefix)
812
881
  yield prefix;
813
- yield prepared.event;
882
+ yield output.event;
814
883
  }
815
884
  }
816
885
  await withCleanupDeadline(closeIterator(), beginCleanup(), watchdog.limits.cancelGraceMs, controller);
@@ -928,6 +997,7 @@ export class AgentExecutor {
928
997
  }
929
998
  }
930
999
  finally {
1000
+ silence?.dispose();
931
1001
  watchdog.finish(outcome);
932
1002
  this.#log("info", "invoke.conversion", {
933
1003
  run_id: request.runId,
@@ -1132,6 +1202,21 @@ function capacityFailureDetails(error) {
1132
1202
  .filter((key) => Object.hasOwn(input, key))
1133
1203
  .map((key) => [key, input[key]]));
1134
1204
  }
1205
+ /** 等待真实源输出或一个静默事实;每次退出释放唯一 notice 监听与 timer。 */
1206
+ async function waitForProviderOutput(pending, signal, silence) {
1207
+ if (!silence)
1208
+ return waitForNext(pending, signal);
1209
+ let detach;
1210
+ try {
1211
+ const notice = new Promise((resolve) => {
1212
+ detach = silence.listen(() => resolve("notice"));
1213
+ });
1214
+ return await waitForNext(Promise.race([pending, notice]), signal);
1215
+ }
1216
+ finally {
1217
+ detach?.();
1218
+ }
1219
+ }
1135
1220
  async function waitForNext(pending, signal) {
1136
1221
  let onAbort = () => { };
1137
1222
  try {
@@ -0,0 +1,21 @@
1
+ import type { ProviderActivity } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
+ import { type CanonicalEvent } from "@mininglamp-oss/octo-runtime-protocol";
3
+ import type { WatchdogClock } from "./watchdog.js";
4
+ /**
5
+ * 每轮 canonical 执行独占的模型输出观察器;不改变 watchdog 预算或 Provider。
6
+ * Core 在源 next 完成时交入事实,在等待下一个结果时订阅通知;只保留一个待发槽。
7
+ * 消息身份、公开性和文本增量由 Core 已有的消息准备步骤判断,不再维护第二套消息缓存。
8
+ */
9
+ export declare class ModelOutputSilence {
10
+ #private;
11
+ readonly time: WatchdogClock;
12
+ constructor(time?: WatchdogClock);
13
+ /** 唯一等待者;解除监听同时释放 timer,避免输出密集时累积 Promise 监听。 */
14
+ listen(wake: () => void): () => void;
15
+ take(): CanonicalEvent | undefined;
16
+ /** 原生侧工具事实补充 canonical;usage、传输心跳及一般进展均不算模型文本。 */
17
+ activity(activity: ProviderActivity): void;
18
+ /** 输入须先通过 canonical 校验;hasOutput 只接受 Core 准备后的公开新增文本事实。 */
19
+ canonical(event: CanonicalEvent, hasOutput?: boolean): void;
20
+ dispose(): void;
21
+ }
@@ -0,0 +1,189 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { performance } from "node:perf_hooks";
3
+ import { isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
4
+ const THRESHOLD_MS = 60_000;
5
+ const clock = {
6
+ now: () => performance.now(),
7
+ schedule(callback, delay) {
8
+ const timer = setTimeout(callback, delay);
9
+ timer.unref?.();
10
+ return () => clearTimeout(timer);
11
+ }
12
+ };
13
+ /**
14
+ * 每轮 canonical 执行独占的模型输出观察器;不改变 watchdog 预算或 Provider。
15
+ * Core 在源 next 完成时交入事实,在等待下一个结果时订阅通知;只保留一个待发槽。
16
+ * 消息身份、公开性和文本增量由 Core 已有的消息准备步骤判断,不再维护第二套消息缓存。
17
+ */
18
+ export class ModelOutputSilence {
19
+ time;
20
+ #tools = new Set();
21
+ #interactions = new Set();
22
+ #activities = new Map();
23
+ #queued = false;
24
+ #interval;
25
+ #disposed = false;
26
+ #pending;
27
+ #listener;
28
+ #timer;
29
+ constructor(time = clock) {
30
+ this.time = time;
31
+ this.#reset();
32
+ }
33
+ /** 唯一等待者;解除监听同时释放 timer,避免输出密集时累积 Promise 监听。 */
34
+ listen(wake) {
35
+ if (this.#disposed)
36
+ return () => { };
37
+ const listener = { wake };
38
+ this.#listener = listener;
39
+ if (this.#pending)
40
+ wake();
41
+ else
42
+ this.#arm();
43
+ return () => {
44
+ // 同一个回调也可重复订阅,旧 detach 只能解除自己那次订阅。
45
+ if (this.#listener !== listener)
46
+ return;
47
+ this.#listener = undefined;
48
+ this.#clearTimer();
49
+ };
50
+ }
51
+ take() {
52
+ const pending = this.#pending;
53
+ this.#pending = undefined;
54
+ // 背压不改写已生成事实,也不补齐同段错过的分钟;旧段槽不能推进新段节点。
55
+ if (pending && pending.interval === this.#interval)
56
+ this.#advance(pending.interval);
57
+ this.#arm();
58
+ return pending?.event;
59
+ }
60
+ /** 原生侧工具事实补充 canonical;usage、传输心跳及一般进展均不算模型文本。 */
61
+ activity(activity) {
62
+ if (this.#disposed)
63
+ return;
64
+ if (activity.kind !== "turn_progress" ||
65
+ activity.method !== "item_lifecycle" ||
66
+ !activity.toolCallId)
67
+ return;
68
+ if (activity.toolState === "started")
69
+ this.#tools.add(activity.toolCallId);
70
+ else if (activity.toolState === "completed")
71
+ this.#finishTool(activity.toolCallId);
72
+ this.#sync();
73
+ }
74
+ /** 输入须先通过 canonical 校验;hasOutput 只接受 Core 准备后的公开新增文本事实。 */
75
+ canonical(event, hasOutput = false) {
76
+ if (this.#disposed)
77
+ return;
78
+ if (isTerminal(event)) {
79
+ this.dispose();
80
+ return;
81
+ }
82
+ const p = event.payload;
83
+ if (event.type === "run.queued")
84
+ this.#queued = true;
85
+ if (event.type === "run.started" || event.type === "model_step.started")
86
+ this.#queued = false;
87
+ if (event.type === "tool_call.create")
88
+ this.#tools.add(String(p.id));
89
+ if (event.type === "tool_call.update" &&
90
+ ["completed", "failed", "cancelled", "stopped"].includes(String(p.status)))
91
+ this.#finishTool(String(p.id));
92
+ if (event.type === "interaction.requested" && p.delivery !== "async")
93
+ this.#interactions.add(String(p.interactionId));
94
+ if (event.type === "interaction.resolved") {
95
+ const id = String(p.interactionId);
96
+ this.#interactions.delete(id);
97
+ for (const [key, subject] of this.#activities)
98
+ if (subject.type === "interaction" && subject.id === id)
99
+ this.#activities.delete(key);
100
+ }
101
+ if (event.type === "activity.started") {
102
+ this.#queued = false;
103
+ if (["executing_tool", "waiting_input", "waiting_approval"].includes(event.payload.kind))
104
+ this.#activities.set(event.payload.activityId, event.payload.subject);
105
+ }
106
+ if (event.type === "activity.finished")
107
+ this.#activities.delete(event.payload.activityId);
108
+ if (hasOutput)
109
+ this.#reset();
110
+ this.#sync();
111
+ }
112
+ dispose() {
113
+ this.#disposed = true;
114
+ this.#reset();
115
+ this.#pending = undefined;
116
+ this.#interval = undefined;
117
+ this.#listener = undefined;
118
+ this.#tools.clear();
119
+ this.#interactions.clear();
120
+ this.#activities.clear();
121
+ }
122
+ #finishTool(id) {
123
+ this.#tools.delete(id);
124
+ for (const [key, subject] of this.#activities)
125
+ if (subject.type === "tool" && subject.id === id)
126
+ this.#activities.delete(key);
127
+ }
128
+ #reset() {
129
+ this.#clearTimer();
130
+ // 重置未来静默区间,不撤回已达到阈值、尚未被 Core 取走的通知事实。
131
+ this.#interval = { since: this.time.now(), nextMs: THRESHOLD_MS };
132
+ }
133
+ #sync() {
134
+ if (this.#queued || this.#tools.size || this.#interactions.size || this.#activities.size) {
135
+ this.#reset();
136
+ this.#interval = undefined;
137
+ }
138
+ else if (!this.#interval)
139
+ this.#reset();
140
+ this.#arm();
141
+ }
142
+ #clearTimer() {
143
+ const timer = this.#timer;
144
+ this.#timer = undefined;
145
+ timer?.cancel?.();
146
+ }
147
+ #advance(interval) {
148
+ interval.nextMs = Math.max(interval.nextMs, (Math.floor((this.time.now() - interval.since) / THRESHOLD_MS) + 1) * THRESHOLD_MS);
149
+ }
150
+ #arm() {
151
+ this.#clearTimer();
152
+ const interval = this.#interval;
153
+ const listener = this.#listener;
154
+ if (this.#disposed || !listener || !interval || this.#pending)
155
+ return;
156
+ // 分别校验段、订阅和 timer 身份;同一时刻重置或重订阅也使旧 callback 失效。
157
+ const timer = {};
158
+ this.#timer = timer;
159
+ timer.cancel = this.time.schedule(() => {
160
+ if (this.#disposed ||
161
+ this.#interval !== interval ||
162
+ this.#listener !== listener ||
163
+ this.#timer !== timer ||
164
+ this.#pending)
165
+ return;
166
+ this.#clearTimer();
167
+ const silenceMs = Math.max(0, Math.floor(this.time.now() - interval.since));
168
+ if (silenceMs < interval.nextMs) {
169
+ this.#arm();
170
+ return;
171
+ }
172
+ this.#advance(interval);
173
+ this.#pending = {
174
+ interval,
175
+ event: {
176
+ protocolVersion: 2,
177
+ type: "run.notice",
178
+ payload: {
179
+ noticeId: randomUUID(),
180
+ code: "model_output_idle",
181
+ severity: "info",
182
+ params: { silenceMs, message: `${Math.floor(silenceMs / 1000)}s no LLM output` }
183
+ }
184
+ }
185
+ };
186
+ listener.wake();
187
+ }, Math.max(1, interval.nextMs - (this.time.now() - interval.since)));
188
+ }
189
+ }
@@ -8,7 +8,6 @@ export declare const DEFAULT_RUNTIME_LIMITS: {
8
8
  toolTimeoutMs: number;
9
9
  runTimeoutMs: number;
10
10
  cancelGraceMs: number;
11
- enforcement: "enforce";
12
11
  };
13
12
  export type EffectiveLimits = Required<Omit<RuntimeLimits, "toolWallTimeoutMs">> & Pick<RuntimeLimits, "toolWallTimeoutMs">;
14
13
  export declare function normalizeRuntimeLimits(value: RuntimeLimits | undefined): EffectiveLimits;
@@ -7,8 +7,7 @@ export const DEFAULT_RUNTIME_LIMITS = {
7
7
  modelIdlePolicy: "enforce",
8
8
  toolTimeoutMs: 600_000,
9
9
  runTimeoutMs: DEFAULT_RUN_TIMEOUT_MS,
10
- cancelGraceMs: 1_000,
11
- enforcement: "enforce"
10
+ cancelGraceMs: 1_000
12
11
  };
13
12
  export function normalizeRuntimeLimits(value) {
14
13
  return { ...DEFAULT_RUNTIME_LIMITS, ...value };
@@ -322,8 +321,8 @@ export class InvocationWatchdog {
322
321
  }
323
322
  #arm() {
324
323
  this.#cancelTimer?.();
325
- if (!this.#active() || this.limits.enforcement === "observe")
326
- return; // legacy opt-out
324
+ if (!this.#active())
325
+ return;
327
326
  const now = this.time.now();
328
327
  const deadlines = [
329
328
  {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-executor-core",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
7
7
  "dependencies": {
8
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13",
9
- "@mininglamp-oss/octo-runtime-protocol": "1.1.13"
8
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.15",
9
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.15"
10
10
  },
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-executor-kernel",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,10 +10,10 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@mininglamp-oss/octo-runtime-client": "1.1.13",
14
- "@mininglamp-oss/octo-runtime-executor-core": "1.1.13",
15
- "@mininglamp-oss/octo-runtime-protocol": "1.1.13",
16
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13"
13
+ "@mininglamp-oss/octo-runtime-client": "1.1.15",
14
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.15",
15
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.15",
16
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.15"
17
17
  },
18
18
  "types": "./dist/index.d.ts",
19
19
  "files": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-host-sdk",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,9 +10,9 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13",
14
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.13",
15
- "@mininglamp-oss/octo-runtime-protocol": "1.1.13"
13
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.15",
14
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.15",
15
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.15"
16
16
  },
17
17
  "types": "./dist/index.d.ts",
18
18
  "files": [
@@ -1,7 +1,7 @@
1
1
  import type { AdapterProtocolSupport } from "./run-protocol.js";
2
2
  import type { HostedAdapterMetadataWire } from "./generated/protocol-types.js";
3
3
  /** 宿主注册及执行时使用的完整元数据;编写时的可选默认值须由 Adapter 工厂先补齐。 */
4
- export type HostedAdapterMetadata = Pick<HostedAdapterMetadataWire, "workspace" | "type" | "agentSources" | "processModel" | "transport" | "providerVersion" | "providerPath" | "available" | "unavailableReason"> & {
4
+ export type HostedAdapterMetadata = Pick<HostedAdapterMetadataWire, "workspace" | "type" | "processModel" | "transport" | "providerVersion" | "providerPath" | "available" | "unavailableReason"> & {
5
5
  /** wire 可省略的编写输入不能放宽 Core 注册合同。 */
6
6
  protocolSupport: AdapterProtocolSupport;
7
7
  };
@@ -10,15 +10,11 @@ function entry(namespace, name, schema, persistent) {
10
10
  export const CONTEXT_TYPE_CATALOG = Object.freeze([
11
11
  entry("octo.execution", "adapter", "ContextAdapterPayload", true),
12
12
  entry("octo.execution", "model", "ContextModelPayload", true),
13
- entry("octo.execution", "actmode", "ContextActmodePayload", true),
14
13
  entry("octo.execution", "workspace", "ContextWorkspacePayload", true),
15
14
  entry("octo.execution", "envs", "ContextEnvsPayload", true),
16
15
  entry("octo.execution", "mcp", "ContextMcpPayload", true),
17
16
  entry("octo.execution", "limits", "ContextLimitsPayload", true),
18
- entry("octo.runtime", "selection", "ContextRuntimeSelectionPayload", true),
19
- entry("octo.security", "approval_policy", "ContextApprovalPolicyPayload", true),
20
- entry("octo.content", "inline", "ContextInlinePayload", false),
21
- entry("octo.content", "references", "ContextReferencesPayload", false)
17
+ entry("octo.security", "approval_policy", "ContextApprovalPolicyPayload", true)
22
18
  ]);
23
19
  export function contextTypeDefinition(namespace, name) {
24
20
  const definition = findContextTypeDefinition(namespace, name);
@@ -2,7 +2,6 @@ import type { ApprovalMode, ContextEnvsPayload, ContextEnvelope, ContextItem, Mc
2
2
  export declare const CONTEXT_SCHEMA: "octo.context-envelope/v3";
3
3
  export declare const RUNTIME_RUN_CONTRACT: Readonly<{
4
4
  readonly schema_version: 7;
5
- readonly routing_schema: "octo.runtime-selection/v2";
6
5
  readonly context_schema: "octo.context-envelope/v3";
7
6
  readonly approval_schema: "octo.approval-request/v1";
8
7
  }>;
@@ -11,7 +10,6 @@ export declare const CONTEXT_MAX_ITEMS = 32;
11
10
  export declare const DEFAULT_RUN_TIMEOUT_MS = 86400000;
12
11
  export declare const MAX_RUN_TIMEOUT_MS = 604800000;
13
12
  export declare const APPROVAL_MODES: readonly ApprovalMode[];
14
- export declare function assertAgentSource(value: unknown): asserts value is "preset" | "provisioned";
15
13
  export declare function assertApprovalMode(value: unknown): asserts value is ApprovalMode;
16
14
  export declare function assertContextEnvelope(value: unknown): asserts value is ContextEnvelope;
17
15
  export declare function contextItem(context: ContextEnvelope, namespace: string, name: string): ContextItem | undefined;
@@ -22,7 +20,6 @@ export declare function assertContextMcp(value: unknown): asserts value is {
22
20
  };
23
21
  export declare function assertMcpServers(value: unknown, templates?: boolean): asserts value is McpServers;
24
22
  export declare function assertJsonValue(value: unknown): void;
25
- export declare function mergeReferences(base: Record<string, unknown>[], next: Record<string, unknown>[]): Record<string, unknown>[];
26
23
  /** Environment names are values in a list, never dynamic protocol object keys. */
27
24
  export declare function assertContextEnvs(value: unknown): asserts value is ContextEnvsPayload;
28
25
  export declare function mergeContextEnvs(base: unknown, overrides: unknown): ContextEnvsPayload;
@@ -1,8 +1,6 @@
1
- import { RUNTIME_SELECTION_SCHEMA } from "./runtime-selection.js";
2
1
  export const CONTEXT_SCHEMA = "octo.context-envelope/v3";
3
2
  export const RUNTIME_RUN_CONTRACT = Object.freeze({
4
3
  schema_version: 7,
5
- routing_schema: RUNTIME_SELECTION_SCHEMA,
6
4
  context_schema: CONTEXT_SCHEMA,
7
5
  approval_schema: "octo.approval-request/v1"
8
6
  });
@@ -12,10 +10,6 @@ export const CONTEXT_MAX_ITEMS = 32;
12
10
  export const DEFAULT_RUN_TIMEOUT_MS = 86_400_000;
13
11
  export const MAX_RUN_TIMEOUT_MS = 604_800_000;
14
12
  export const APPROVAL_MODES = ["ask", "assisted", "full_access"];
15
- export function assertAgentSource(value) {
16
- if (value !== "preset" && value !== "provisioned")
17
- throw new TypeError("AGENT_SOURCE_INVALID");
18
- }
19
13
  export function assertApprovalMode(value) {
20
14
  if (!APPROVAL_MODES.includes(value))
21
15
  throw new TypeError("APPROVAL_MODE_UNSUPPORTED");
@@ -33,7 +27,7 @@ export function assertContextEnvelope(value) {
33
27
  object(item, "CONTEXT_SCHEMA_INVALID");
34
28
  if (item.namespace === "octo.control" && item.name === "instructions")
35
29
  throw new TypeError("CONTROL_INSTRUCTIONS_REMOVED: controlInstructions was removed; provide application prompts in inputs.parts");
36
- fields(item, ["namespace", "name", "guidance", "data_format", "payload"]);
30
+ fields(item, ["namespace", "name", "payload"]);
37
31
  for (const property of ["namespace", "name"]) {
38
32
  const text = item[property];
39
33
  if (typeof text !== "string" || text.length > 96 || !/^[a-z0-9][a-z0-9._-]*$/.test(text))
@@ -43,15 +37,7 @@ export function assertContextEnvelope(value) {
43
37
  if (keys.has(key))
44
38
  throw new TypeError("CONTEXT_KEY_DUPLICATED");
45
39
  keys.add(key);
46
- if (item.guidance !== undefined) {
47
- if (typeof item.guidance !== "string")
48
- throw new TypeError("CONTEXT_SCHEMA_INVALID");
49
- }
50
40
  object(item.payload, "CONTEXT_SCHEMA_INVALID");
51
- if (item.data_format !== undefined) {
52
- if (item.data_format !== "text")
53
- throw new TypeError("CONTEXT_SCHEMA_INVALID");
54
- }
55
41
  }
56
42
  if (new TextEncoder().encode(JSON.stringify(value)).length > CONTEXT_MAX_BYTES)
57
43
  throw new TypeError("CONTEXT_BUDGET_EXCEEDED");
@@ -88,13 +74,6 @@ export function mergeContext(defaults, overrides) {
88
74
  ...next.payload.mcpServers
89
75
  }
90
76
  };
91
- if (previous && item.namespace === "octo.runtime" && item.name === "selection") {
92
- for (const field of ["offline_behavior", "failover"])
93
- if (next.payload[field] === undefined && previous.payload[field] !== undefined)
94
- next.payload[field] = previous.payload[field];
95
- }
96
- if (previous && item.namespace === "octo.content" && item.name === "references")
97
- next.payload.entries = mergeReferences(previous.payload.entries, next.payload.entries);
98
77
  items.set(key, next);
99
78
  }
100
79
  const result = { schema: CONTEXT_SCHEMA, items: [...items.values()] };
@@ -221,10 +200,6 @@ function assertMcpTimeout(value, path, maximum) {
221
200
  export function assertJsonValue(value) {
222
201
  json(value, 0);
223
202
  }
224
- export function mergeReferences(base, next) {
225
- const entries = new Map([...base, ...next].map((entry) => [String(entry.resource_ref), structuredClone(entry)]));
226
- return [...entries].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([, entry]) => entry);
227
- }
228
203
  function fields(value, allowed) {
229
204
  if (Object.keys(value).some((key) => !allowed.includes(key)))
230
205
  throw new TypeError("CONTEXT_SCHEMA_INVALID");