@mininglamp-oss/octo-runtime 1.1.13 → 1.1.14
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.
- package/apps/cli/dist/adapters.js +1 -5
- package/apps/cli/dist/build-info.json +2 -2
- package/dist/public/protocol.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +19 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +24 -29
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +23 -24
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +25 -30
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-SMTJTIN7.js → chunk-AE3OJBDS.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-H3S6WM37.js → chunk-NGR74QLF.js} +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-RISQ6NGV.js → chunk-XIUZ6GXG.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +2 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +5 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +8 -18
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +1 -12
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +16 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +16 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +16 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +0 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +2 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +6 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +16 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +16 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +2 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +6 -28
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +2 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +1 -5
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +20 -20
- package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +42 -624
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +97 -12
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.d.ts +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.js +176 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +3 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +1 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +1 -26
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.js +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +3 -12
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +16 -240
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +2 -12
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +0 -12
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +24 -24
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -624
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.d.ts +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.js +0 -8
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.d.ts +0 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.js +0 -36
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.js +0 -68
|
@@ -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
|
-
|
|
608
|
-
|
|
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
|
-
|
|
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) =>
|
|
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
|
-
|
|
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
|
|
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
|
|
811
|
-
for (const prefix of
|
|
879
|
+
const output = prepared ?? prepareMessage(event);
|
|
880
|
+
for (const prefix of output.prefix)
|
|
812
881
|
yield prefix;
|
|
813
|
-
yield
|
|
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 {
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.d.ts
ADDED
|
@@ -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,176 @@
|
|
|
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
|
+
#since;
|
|
25
|
+
#reported = false;
|
|
26
|
+
#disposed = false;
|
|
27
|
+
#pending;
|
|
28
|
+
#wake;
|
|
29
|
+
#cancelTimer;
|
|
30
|
+
constructor(time = clock) {
|
|
31
|
+
this.time = time;
|
|
32
|
+
this.#since = time.now();
|
|
33
|
+
}
|
|
34
|
+
/** 唯一等待者;解除监听同时释放 timer,避免输出密集时累积 Promise 监听。 */
|
|
35
|
+
listen(wake) {
|
|
36
|
+
this.#wake = wake;
|
|
37
|
+
if (this.#pending)
|
|
38
|
+
wake();
|
|
39
|
+
else
|
|
40
|
+
this.#arm();
|
|
41
|
+
return () => {
|
|
42
|
+
if (this.#wake !== wake)
|
|
43
|
+
return;
|
|
44
|
+
this.#wake = undefined;
|
|
45
|
+
this.#cancelTimer?.();
|
|
46
|
+
this.#cancelTimer = undefined;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
take() {
|
|
50
|
+
const notice = this.#pending;
|
|
51
|
+
this.#pending = undefined;
|
|
52
|
+
// 槽交付后才允许新区间计时;使用真实输出更新的 since,不从交付时刻重算。
|
|
53
|
+
this.#arm();
|
|
54
|
+
return notice;
|
|
55
|
+
}
|
|
56
|
+
/** 原生侧工具事实补充 canonical;usage、传输心跳及一般进展均不算模型文本。 */
|
|
57
|
+
activity(activity) {
|
|
58
|
+
if (this.#disposed)
|
|
59
|
+
return;
|
|
60
|
+
if (activity.kind !== "turn_progress" ||
|
|
61
|
+
activity.method !== "item_lifecycle" ||
|
|
62
|
+
!activity.toolCallId)
|
|
63
|
+
return;
|
|
64
|
+
if (activity.toolState === "started")
|
|
65
|
+
this.#tools.add(activity.toolCallId);
|
|
66
|
+
else if (activity.toolState === "completed")
|
|
67
|
+
this.#finishTool(activity.toolCallId);
|
|
68
|
+
this.#sync();
|
|
69
|
+
}
|
|
70
|
+
/** 输入须先通过 canonical 校验;hasOutput 只接受 Core 准备后的公开新增文本事实。 */
|
|
71
|
+
canonical(event, hasOutput = false) {
|
|
72
|
+
if (this.#disposed)
|
|
73
|
+
return;
|
|
74
|
+
if (isTerminal(event)) {
|
|
75
|
+
this.dispose();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const p = event.payload;
|
|
79
|
+
if (event.type === "run.queued")
|
|
80
|
+
this.#queued = true;
|
|
81
|
+
if (event.type === "run.started" || event.type === "model_step.started")
|
|
82
|
+
this.#queued = false;
|
|
83
|
+
if (event.type === "tool_call.create")
|
|
84
|
+
this.#tools.add(String(p.id));
|
|
85
|
+
if (event.type === "tool_call.update" &&
|
|
86
|
+
["completed", "failed", "cancelled", "stopped"].includes(String(p.status)))
|
|
87
|
+
this.#finishTool(String(p.id));
|
|
88
|
+
if (event.type === "interaction.requested" && p.delivery !== "async")
|
|
89
|
+
this.#interactions.add(String(p.interactionId));
|
|
90
|
+
if (event.type === "interaction.resolved") {
|
|
91
|
+
const id = String(p.interactionId);
|
|
92
|
+
this.#interactions.delete(id);
|
|
93
|
+
for (const [key, subject] of this.#activities)
|
|
94
|
+
if (subject.type === "interaction" && subject.id === id)
|
|
95
|
+
this.#activities.delete(key);
|
|
96
|
+
}
|
|
97
|
+
if (event.type === "activity.started") {
|
|
98
|
+
this.#queued = false;
|
|
99
|
+
if (["executing_tool", "waiting_input", "waiting_approval"].includes(event.payload.kind))
|
|
100
|
+
this.#activities.set(event.payload.activityId, event.payload.subject);
|
|
101
|
+
}
|
|
102
|
+
if (event.type === "activity.finished")
|
|
103
|
+
this.#activities.delete(event.payload.activityId);
|
|
104
|
+
if (hasOutput)
|
|
105
|
+
this.#reset();
|
|
106
|
+
this.#sync();
|
|
107
|
+
}
|
|
108
|
+
dispose() {
|
|
109
|
+
this.#disposed = true;
|
|
110
|
+
this.#reset();
|
|
111
|
+
this.#pending = undefined;
|
|
112
|
+
this.#since = undefined;
|
|
113
|
+
this.#wake = undefined;
|
|
114
|
+
this.#tools.clear();
|
|
115
|
+
this.#interactions.clear();
|
|
116
|
+
this.#activities.clear();
|
|
117
|
+
}
|
|
118
|
+
#finishTool(id) {
|
|
119
|
+
this.#tools.delete(id);
|
|
120
|
+
for (const [key, subject] of this.#activities)
|
|
121
|
+
if (subject.type === "tool" && subject.id === id)
|
|
122
|
+
this.#activities.delete(key);
|
|
123
|
+
}
|
|
124
|
+
#reset() {
|
|
125
|
+
this.#cancelTimer?.();
|
|
126
|
+
this.#cancelTimer = undefined;
|
|
127
|
+
// 重置未来静默区间,不撤回已达到阈值、尚未被 Core 取走的通知事实。
|
|
128
|
+
this.#reported = false;
|
|
129
|
+
this.#since = this.time.now();
|
|
130
|
+
}
|
|
131
|
+
#sync() {
|
|
132
|
+
if (this.#queued || this.#tools.size || this.#interactions.size || this.#activities.size) {
|
|
133
|
+
this.#reset();
|
|
134
|
+
this.#since = undefined;
|
|
135
|
+
}
|
|
136
|
+
else if (this.#since === undefined)
|
|
137
|
+
this.#reset();
|
|
138
|
+
this.#arm();
|
|
139
|
+
}
|
|
140
|
+
#arm() {
|
|
141
|
+
this.#cancelTimer?.();
|
|
142
|
+
this.#cancelTimer = undefined;
|
|
143
|
+
if (this.#disposed ||
|
|
144
|
+
!this.#wake ||
|
|
145
|
+
this.#since === undefined ||
|
|
146
|
+
this.#reported ||
|
|
147
|
+
this.#pending)
|
|
148
|
+
return;
|
|
149
|
+
const since = this.#since;
|
|
150
|
+
this.#cancelTimer = this.time.schedule(() => {
|
|
151
|
+
if (this.#disposed ||
|
|
152
|
+
this.#since !== since ||
|
|
153
|
+
!this.#wake ||
|
|
154
|
+
this.#reported ||
|
|
155
|
+
this.#pending)
|
|
156
|
+
return;
|
|
157
|
+
const silenceMs = Math.max(0, Math.floor(this.time.now() - since));
|
|
158
|
+
if (silenceMs < THRESHOLD_MS) {
|
|
159
|
+
this.#arm();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.#reported = true;
|
|
163
|
+
this.#pending = {
|
|
164
|
+
protocolVersion: 2,
|
|
165
|
+
type: "run.notice",
|
|
166
|
+
payload: {
|
|
167
|
+
noticeId: randomUUID(),
|
|
168
|
+
code: "model_output_idle",
|
|
169
|
+
severity: "info",
|
|
170
|
+
params: { silenceMs, message: `${Math.floor(silenceMs / 1000)}s no LLM output` }
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
this.#wake();
|
|
174
|
+
}, Math.max(1, THRESHOLD_MS - (this.time.now() - since)));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -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()
|
|
326
|
-
return;
|
|
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.
|
|
3
|
+
"version": "1.1.14",
|
|
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.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.14",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.14"
|
|
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.
|
|
3
|
+
"version": "1.1.14",
|
|
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.
|
|
14
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
15
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
16
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
13
|
+
"@mininglamp-oss/octo-runtime-client": "1.1.14",
|
|
14
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.14",
|
|
15
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.14",
|
|
16
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.14"
|
|
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.
|
|
3
|
+
"version": "1.1.14",
|
|
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.
|
|
14
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
15
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
13
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.14",
|
|
14
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.14",
|
|
15
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.14"
|
|
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" | "
|
|
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.
|
|
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", "
|
|
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");
|
|
@@ -138,6 +138,13 @@ export function assertExperiencePayload(type, payload) {
|
|
|
138
138
|
if (params.reasonCode !== undefined)
|
|
139
139
|
string(params.reasonCode);
|
|
140
140
|
break;
|
|
141
|
+
case "model_output_idle":
|
|
142
|
+
fields(params, ["silenceMs", "message"], ["silenceMs", "message"]);
|
|
143
|
+
integer(params.silenceMs, 60_000);
|
|
144
|
+
if (payload.severity !== "info" ||
|
|
145
|
+
params.message !== `${Math.floor(Number(params.silenceMs) / 1000)}s no LLM output`)
|
|
146
|
+
throw new TypeError("invalid model output idle notice");
|
|
147
|
+
break;
|
|
141
148
|
case "config_warning":
|
|
142
149
|
fields(params, ["warningCode"], ["warningCode"]);
|
|
143
150
|
string(params.warningCode);
|