@mininglamp-oss/octo-runtime 1.1.7 → 1.1.9
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/README.md +3 -1
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/command-tree.js +3 -1
- package/apps/cli/dist/output.js +5 -2
- package/apps/cli/dist/playboard.js +11 -2
- package/dist/public/executor-kernel.d.ts +2 -2
- package/dist/public/executor-kernel.js +1 -1
- package/dist/public/protocol.d.ts +1 -1
- package/dist/public/protocol.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +200 -106
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/async-questions.d.ts +27 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/async-questions.js +205 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +30 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +223 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-V5W6ZTYC.js → chunk-FGFEM7JP.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-CFKMMCO6.js → chunk-R3PDZLX5.js} +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-LO34KB7D.js → chunk-TSRZVLIG.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-NOTICE.txt +2 -2
- 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.js +5 -5
- 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/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/gateway.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/gateway.js +57 -13
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/approval.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +22 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +14 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +11 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -24
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/launchd.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/launchd.js +12 -11
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/experience.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +7 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +9 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +6 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts +30 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +199 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.js +16 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +36 -19
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +27 -35
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.js +29 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/send-error.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/send-error.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.js +54 -10
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +77 -109
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.d.ts +3 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js +27 -40
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/interaction-card.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +42 -7
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/session-command.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/session-command.js +71 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +1 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +6 -126
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/{index-CXTvRGim.js → index-BVxePruX.js} +11 -10
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +63 -12
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +110 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +7 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +28 -6
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.js +84 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +11 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +27 -27
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +156 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/text-send.d.ts +0 -19
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/text-send.js +0 -86
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/delivery-notice.d.ts +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/delivery-notice.js +0 -35
|
@@ -90,7 +90,8 @@ export class InvocationExperience {
|
|
|
90
90
|
}
|
|
91
91
|
if (event.type === "tool_call.update")
|
|
92
92
|
output.push(...this.#finish(`tool:${event.payload.id}`, canonicalTerminalStatus(payload.status)));
|
|
93
|
-
|
|
93
|
+
// 异步问题等待的是用户回答,不表示 Provider 暂停执行。
|
|
94
|
+
if (event.type === "interaction.requested" && event.payload.delivery !== "async")
|
|
94
95
|
output.push(...this.#begin(`interaction:${event.payload.interactionId}`, payload.kind === "approval" ? "waiting_approval" : "waiting_input", { type: "interaction", id: String(payload.interactionId) }));
|
|
95
96
|
if (event.type === "interaction.resolved")
|
|
96
97
|
output.push(...this.#finish(`interaction:${String(payload.interactionId)}`, payload.status === "resolved" ? "completed" : "cancelled"));
|
|
@@ -21,9 +21,10 @@ export interface HostedAdapterMetadata {
|
|
|
21
21
|
unavailableReason?: string | null;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* invoke
|
|
26
|
-
*
|
|
24
|
+
* Adapter 的最小注册合同;必须声明实际支持的输出模式。
|
|
25
|
+
* invoke 可封装子进程、ACP、WebSocket 或进程内实现,按 context.protocolMode
|
|
26
|
+
* 返回 canonical 事件或 native/控制输出;native-only 不要求生成 canonical 事件。
|
|
27
|
+
* Adapter 负责本轮取消和资源清理,Core 在清理结束后发布执行终态。
|
|
27
28
|
*/
|
|
28
29
|
export interface HostedAdapter {
|
|
29
30
|
metadata: HostedAdapterMetadata;
|
|
@@ -71,7 +72,7 @@ export declare class AgentExecutor {
|
|
|
71
72
|
probe(adapterType: string, options?: AdapterProbeOptions): unknown;
|
|
72
73
|
/** 请求取消活动执行;true 仅表示已触发 abort,仍须消费终态并等待 Adapter 清理。 */
|
|
73
74
|
cancel(invocationId: string, reason?: string): boolean;
|
|
74
|
-
/**
|
|
75
|
+
/** 仅将回答路由到原活动调用;终态后返回稳定失效码,不转交其他 Adapter 或轮次。 */
|
|
75
76
|
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
76
77
|
respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
|
|
77
78
|
/**
|
|
@@ -6,7 +6,7 @@ import { sanitizePublicValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
|
6
6
|
export { prepareInvokeInput } from "./invoke-input.js";
|
|
7
7
|
export { resolveLocalContext, localRuntimeLimits } from "./context.js";
|
|
8
8
|
export { prepareRunContext } from "./execution-preparation.js";
|
|
9
|
-
import { createInputInvoke, assertInvokeRequestSize, assertProtocolSupport, assertAdapterProtocolSupport, assertHostFrame, assertHostFrameIdentity, assertNativeInteractionResponse, resolveHostInvokeOptions, protocolError, assertCanonicalEvent, assertInteractionResponse, assertInvokeRequest, failurePayload, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError, isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
|
|
9
|
+
import { createInputInvoke, assertInvokeRequestSize, assertProtocolSupport, assertAdapterProtocolSupport, assertHostFrame, assertHostFrameIdentity, assertNativeInteractionResponse, resolveHostInvokeOptions, protocolError, assertCanonicalEvent, assertInteractionResponse, assertInvokeRequest, failurePayload, isCodexLocalFailure, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError, isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
|
|
10
10
|
import { InvocationExperience } from "./experience.js";
|
|
11
11
|
import { withModelContexts } from "./model-input.js";
|
|
12
12
|
import { noopRuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
@@ -803,7 +803,10 @@ export class AgentExecutor {
|
|
|
803
803
|
? nativeFailureCode
|
|
804
804
|
: "HOST_EXECUTION_FAILED",
|
|
805
805
|
message: String(failure.message),
|
|
806
|
-
...(isStreamCapacityReason(nativeFailureCode)
|
|
806
|
+
...(isStreamCapacityReason(nativeFailureCode) ||
|
|
807
|
+
(adapterType === "codex" && isCodexLocalFailure(failure.failure))
|
|
808
|
+
? { failure: failure.failure }
|
|
809
|
+
: {})
|
|
807
810
|
}
|
|
808
811
|
};
|
|
809
812
|
yield {
|
|
@@ -870,12 +873,12 @@ export class AgentExecutor {
|
|
|
870
873
|
this.#log("info", "invoke.cancel_accepted", { invocation_id: invocationId });
|
|
871
874
|
return true;
|
|
872
875
|
}
|
|
873
|
-
/**
|
|
876
|
+
/** 仅将回答路由到原活动调用;终态后返回稳定失效码,不转交其他 Adapter 或轮次。 */
|
|
874
877
|
async respondInteraction(invocationId, response) {
|
|
875
878
|
assertInteractionResponse(response);
|
|
876
879
|
const adapter = this.#activeAdapters.get(invocationId);
|
|
877
880
|
if (!adapter || this.#acceptedTerminals.has(invocationId)) {
|
|
878
|
-
throw
|
|
881
|
+
throw protocolError("INTERACTION_NOT_ACTIVE", `invocation is not active: ${invocationId}`);
|
|
879
882
|
}
|
|
880
883
|
if (this.#modes.get(invocationId) !== "canonical")
|
|
881
884
|
throw protocolError("EXECUTION_PROTOCOL_MISMATCH");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { localRuntimeLimits, resolveLocalContext } from "./context.js";
|
|
3
|
-
import { CONTEXT_SCHEMA, assertAgentSource, assertContextEnvelope, assertInvokeRequest, contextControlInstructions, contextItem, InvokeInput } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
import { CONTEXT_SCHEMA, DEFAULT_RUN_TIMEOUT_MS, assertAgentSource, assertContextEnvelope, assertInvokeRequest, contextControlInstructions, contextItem, InvokeInput } from "@mininglamp-oss/octo-runtime-protocol";
|
|
4
4
|
/** CLI shorthand resolves execution defaults before entering the strict Context contract. */
|
|
5
5
|
function inputContext(value) {
|
|
6
6
|
if (isRecord(value) && Array.isArray(value.items)) {
|
|
@@ -58,6 +58,9 @@ export function prepareInvokeInput(value) {
|
|
|
58
58
|
typeof value.providerSession.resumable !== "boolean") {
|
|
59
59
|
throw new TypeError("providerSession.resumable must be a boolean");
|
|
60
60
|
}
|
|
61
|
+
if (value.providerSession.requireResume !== undefined &&
|
|
62
|
+
typeof value.providerSession.requireResume !== "boolean")
|
|
63
|
+
throw new TypeError("providerSession.requireResume must be a boolean");
|
|
61
64
|
providerSession = structuredClone(value.providerSession);
|
|
62
65
|
}
|
|
63
66
|
if (continuityMode === "fresh" && providerSession)
|
|
@@ -82,7 +85,11 @@ export function prepareInvokeInput(value) {
|
|
|
82
85
|
name: "approval_policy",
|
|
83
86
|
payload: { mode: input.approvalMode ?? "ask" }
|
|
84
87
|
},
|
|
85
|
-
{
|
|
88
|
+
{
|
|
89
|
+
namespace: "octo.execution",
|
|
90
|
+
name: "limits",
|
|
91
|
+
payload: { run_timeout_ms: DEFAULT_RUN_TIMEOUT_MS }
|
|
92
|
+
}
|
|
86
93
|
]
|
|
87
94
|
};
|
|
88
95
|
// Resolve only execution settings here. Business items and control instructions
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
|
|
1
|
+
import { isTerminal, DEFAULT_RUN_TIMEOUT_MS } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
2
|
import { performance } from "node:perf_hooks";
|
|
3
3
|
export const DEFAULT_RUNTIME_LIMITS = {
|
|
4
4
|
firstFrameTimeoutMs: 60_000,
|
|
@@ -6,7 +6,7 @@ export const DEFAULT_RUNTIME_LIMITS = {
|
|
|
6
6
|
modelIdleWarningMs: 120_000,
|
|
7
7
|
modelIdlePolicy: "enforce",
|
|
8
8
|
toolTimeoutMs: 600_000,
|
|
9
|
-
runTimeoutMs:
|
|
9
|
+
runTimeoutMs: DEFAULT_RUN_TIMEOUT_MS,
|
|
10
10
|
cancelGraceMs: 1_000,
|
|
11
11
|
enforcement: "enforce"
|
|
12
12
|
};
|
|
@@ -162,7 +162,10 @@ export class InvocationWatchdog {
|
|
|
162
162
|
toolChanged = this.#tools.delete(id);
|
|
163
163
|
this.#finishSubjectActivities("tool", id);
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
// 非阻塞问题不授予等待豁免;原模型/工具仍按真实进度计时。
|
|
166
|
+
if (event.type === "interaction.requested" &&
|
|
167
|
+
event.payload.delivery !== "async" &&
|
|
168
|
+
typeof event.payload.interactionId === "string") {
|
|
166
169
|
this.#interaction(event.payload.interactionId, true);
|
|
167
170
|
}
|
|
168
171
|
if (event.type === "interaction.resolved" && typeof event.payload.interactionId === "string") {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-executor-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
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.9",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9"
|
|
10
10
|
},
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"files": [
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type AsyncQuestionReplySnapshot, type CanonicalEvent, type HostFrame, type InvokeEnvironment, type InvokeInput } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
|
+
import { type KernelClient } from "./types.js";
|
|
3
|
+
export type AsyncQuestionReplyResult = {
|
|
4
|
+
route: "steer";
|
|
5
|
+
acceptance: "provider_accepted";
|
|
6
|
+
} | {
|
|
7
|
+
route: "new_run";
|
|
8
|
+
input: InvokeInput;
|
|
9
|
+
events: AsyncGenerator<CanonicalEvent>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 宿主持有的一份旁路问题控制者,不拥有 Kernel 或数据库。
|
|
13
|
+
* 活动时 steer,确认正常完成后复用 invoke;宿主须串行管理同会话、
|
|
14
|
+
* 保存提交状态并消费新 Run 尾流。新流返回不代表 Provider 接纳。
|
|
15
|
+
*/
|
|
16
|
+
export declare class AsyncQuestionReply {
|
|
17
|
+
#private;
|
|
18
|
+
readonly client: KernelClient;
|
|
19
|
+
readonly continuation: () => InvokeInput;
|
|
20
|
+
readonly environment?: InvokeEnvironment | undefined;
|
|
21
|
+
constructor(client: KernelClient, snapshot: AsyncQuestionReplySnapshot, continuation: () => InvokeInput, environment?: InvokeEnvironment | undefined);
|
|
22
|
+
/** 独立 JSON 副本供宿主保存;恢复 submitting/unknown 不会再次投递。 */
|
|
23
|
+
snapshot(): AsyncQuestionReplySnapshot;
|
|
24
|
+
/** 只接受原源流事实;消息 final 或查不到 Run 不能证明正常完成。 */
|
|
25
|
+
observe(frame: HostFrame): void;
|
|
26
|
+
/** 关闭旁路,不中断模型;原活动交互同步关闭,未知响应不重试。 */
|
|
27
|
+
cancel(): Promise<void>;
|
|
28
|
+
/** 整批一次。steer 等待 Provider ACK;new_run 必须消费返回流,沿原 invoke 管理执行。 */
|
|
29
|
+
respond(value: unknown): Promise<AsyncQuestionReplyResult>;
|
|
30
|
+
}
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { assertCanonicalEvent, assertHostFrame, assertHostFrameIdentity, assertHostRunReceipt, assertInvokeInput, assertJsonValue, assertQuestionRequest, assertQuestionResponse, questionAnswerText } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
import { KernelError } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* 宿主持有的一份旁路问题控制者,不拥有 Kernel 或数据库。
|
|
6
|
+
* 活动时 steer,确认正常完成后复用 invoke;宿主须串行管理同会话、
|
|
7
|
+
* 保存提交状态并消费新 Run 尾流。新流返回不代表 Provider 接纳。
|
|
8
|
+
*/
|
|
9
|
+
export class AsyncQuestionReply {
|
|
10
|
+
client;
|
|
11
|
+
continuation;
|
|
12
|
+
environment;
|
|
13
|
+
#snapshot;
|
|
14
|
+
constructor(client, snapshot, continuation, environment) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
this.continuation = continuation;
|
|
17
|
+
this.environment = environment;
|
|
18
|
+
assertJsonValue(snapshot);
|
|
19
|
+
if (snapshot.schema !== "octo.async-question-reply/v1" ||
|
|
20
|
+
!["pending", "submitting", "answered", "cancelled", "invalidated", "unknown"].includes(snapshot.phase) ||
|
|
21
|
+
typeof snapshot.completed !== "boolean" ||
|
|
22
|
+
snapshot.ref.protocol_mode !== "canonical" ||
|
|
23
|
+
snapshot.ref.protocol !== "codex.app-server" ||
|
|
24
|
+
snapshot.question.delivery !== "async" ||
|
|
25
|
+
snapshot.question.kind !== "question" ||
|
|
26
|
+
snapshot.question.executionInstanceId !== snapshot.ref.invocation_id ||
|
|
27
|
+
!snapshot.providerSession.sessionId ||
|
|
28
|
+
snapshot.providerSession.resumable === false)
|
|
29
|
+
throw new KernelError("INVALID_ASYNC_QUESTION_SNAPSHOT");
|
|
30
|
+
const { kernel_instance_id, ...receipt } = snapshot.ref;
|
|
31
|
+
if (!kernel_instance_id)
|
|
32
|
+
throw new KernelError("INVALID_ASYNC_QUESTION_SNAPSHOT");
|
|
33
|
+
assertHostRunReceipt(receipt);
|
|
34
|
+
assertCanonicalEvent({
|
|
35
|
+
protocolVersion: 2,
|
|
36
|
+
type: "interaction.requested",
|
|
37
|
+
payload: snapshot.question
|
|
38
|
+
});
|
|
39
|
+
assertQuestionRequest(snapshot.question.request);
|
|
40
|
+
this.#snapshot = structuredClone(snapshot);
|
|
41
|
+
}
|
|
42
|
+
/** 独立 JSON 副本供宿主保存;恢复 submitting/unknown 不会再次投递。 */
|
|
43
|
+
snapshot() {
|
|
44
|
+
return structuredClone(this.#snapshot);
|
|
45
|
+
}
|
|
46
|
+
/** 只接受原源流事实;消息 final 或查不到 Run 不能证明正常完成。 */
|
|
47
|
+
observe(frame) {
|
|
48
|
+
assertHostFrame(frame);
|
|
49
|
+
const { kernel_instance_id: _instance, ...receipt } = this.#snapshot.ref;
|
|
50
|
+
void _instance;
|
|
51
|
+
assertHostFrameIdentity(frame, receipt);
|
|
52
|
+
if (frame.kind === "control" && frame.control.type === "state") {
|
|
53
|
+
if (frame.control.state === "completed")
|
|
54
|
+
this.#snapshot.completed = true;
|
|
55
|
+
else if (["failed", "cancelled", "lost"].includes(frame.control.state))
|
|
56
|
+
this.#snapshot.phase = "invalidated";
|
|
57
|
+
}
|
|
58
|
+
if (frame.kind === "canonical" &&
|
|
59
|
+
frame.event.type === "interaction.resolved" &&
|
|
60
|
+
frame.event.payload.interactionId === this.#snapshot.question.interactionId) {
|
|
61
|
+
const payload = frame.event.payload;
|
|
62
|
+
this.#snapshot.phase =
|
|
63
|
+
payload.reasonCode === "provider_accepted"
|
|
64
|
+
? "answered"
|
|
65
|
+
: payload.reasonCode === "submission_outcome_unknown"
|
|
66
|
+
? "unknown"
|
|
67
|
+
: "invalidated";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** 关闭旁路,不中断模型;原活动交互同步关闭,未知响应不重试。 */
|
|
71
|
+
async cancel() {
|
|
72
|
+
this.#assertPending();
|
|
73
|
+
this.#snapshot.phase = "cancelled";
|
|
74
|
+
if (!this.#snapshot.completed) {
|
|
75
|
+
try {
|
|
76
|
+
await this.client.respond(this.#snapshot.ref, {
|
|
77
|
+
interactionId: this.#snapshot.question.interactionId,
|
|
78
|
+
outcome: "cancelled"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (!(error instanceof KernelError) || error.code !== "INTERACTION_NOT_ACTIVE")
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** 整批一次。steer 等待 Provider ACK;new_run 必须消费返回流,沿原 invoke 管理执行。 */
|
|
88
|
+
async respond(value) {
|
|
89
|
+
this.#assertPending();
|
|
90
|
+
const original = this.#snapshot;
|
|
91
|
+
assertQuestionRequest(original.question.request);
|
|
92
|
+
const answer = structuredClone(value);
|
|
93
|
+
assertQuestionResponse(answer);
|
|
94
|
+
const text = questionAnswerText(original.question.request, answer);
|
|
95
|
+
const next = structuredClone(this.continuation());
|
|
96
|
+
assertInvokeInput(next);
|
|
97
|
+
// 现有会话由宿主显式提供,旧题不能跨 reset 或 Provider binding 改投。
|
|
98
|
+
if (next.sessionId !== original.ref.agent_session_id ||
|
|
99
|
+
(next.sessionGeneration ?? 0) !== original.ref.session_generation ||
|
|
100
|
+
next.providerSession?.sessionId !== original.providerSession.sessionId ||
|
|
101
|
+
next.providerSession?.resumable === false ||
|
|
102
|
+
next.providerEpoch !== original.providerEpoch)
|
|
103
|
+
throw new KernelError("ASYNC_QUESTION_SESSION_STALE");
|
|
104
|
+
original.phase = "submitting";
|
|
105
|
+
let attempted = false;
|
|
106
|
+
try {
|
|
107
|
+
if (!original.completed) {
|
|
108
|
+
const current = await this.client.get(original.ref, original.ref.kernel_instance_id);
|
|
109
|
+
if (current.terminal)
|
|
110
|
+
this.observe(current.terminal);
|
|
111
|
+
if (this.snapshot().phase === "invalidated")
|
|
112
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
113
|
+
}
|
|
114
|
+
if (!original.completed) {
|
|
115
|
+
attempted = true;
|
|
116
|
+
try {
|
|
117
|
+
this.#assertNotExpired();
|
|
118
|
+
await this.client.respond(original.ref, {
|
|
119
|
+
interactionId: original.question.interactionId,
|
|
120
|
+
outcome: "answered",
|
|
121
|
+
value: answer
|
|
122
|
+
});
|
|
123
|
+
original.phase = "answered";
|
|
124
|
+
return { route: "steer", acceptance: "provider_accepted" };
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (!(error instanceof KernelError) ||
|
|
128
|
+
!["INTERACTION_NOT_ACTIVE", "ASYNC_ANSWER_REJECTED"].includes(error.code))
|
|
129
|
+
throw error;
|
|
130
|
+
// 仅明确未接纳才可在正常终态之后续跑;ACK 丢失和写后失联绝不进入此分支。
|
|
131
|
+
attempted = false;
|
|
132
|
+
const current = await this.client.get(original.ref, original.ref.kernel_instance_id);
|
|
133
|
+
if (current.terminal)
|
|
134
|
+
this.observe(current.terminal);
|
|
135
|
+
if (!original.completed) {
|
|
136
|
+
original.phase = "invalidated";
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const input = {
|
|
142
|
+
...next,
|
|
143
|
+
runId: randomUUID(),
|
|
144
|
+
invocationId: randomUUID(),
|
|
145
|
+
protocol_mode: "canonical",
|
|
146
|
+
continuityMode: "continue",
|
|
147
|
+
inputs: [{ type: "text", text }],
|
|
148
|
+
prompt: text,
|
|
149
|
+
modelInput: text,
|
|
150
|
+
providerSession: { ...original.providerSession, requireResume: true },
|
|
151
|
+
freshFallbackModelInput: text,
|
|
152
|
+
freshFallbackModelInputParts: [{ type: "text", text }]
|
|
153
|
+
};
|
|
154
|
+
const client = this.client, environment = this.environment;
|
|
155
|
+
const beforeInvoke = () => {
|
|
156
|
+
this.#assertNotExpired();
|
|
157
|
+
const currentInput = this.continuation();
|
|
158
|
+
if (currentInput.sessionId !== input.sessionId ||
|
|
159
|
+
(currentInput.sessionGeneration ?? 0) !== original.ref.session_generation ||
|
|
160
|
+
currentInput.providerSession?.sessionId !== original.providerSession.sessionId ||
|
|
161
|
+
currentInput.providerEpoch !== original.providerEpoch)
|
|
162
|
+
throw new KernelError("ASYNC_QUESTION_SESSION_STALE");
|
|
163
|
+
};
|
|
164
|
+
const events = (async function* () {
|
|
165
|
+
try {
|
|
166
|
+
beforeInvoke();
|
|
167
|
+
for await (const event of client.invoke(input, environment)) {
|
|
168
|
+
if (event.type === "session.update" &&
|
|
169
|
+
event.payload.providerSession?.sessionId === original.providerSession.sessionId &&
|
|
170
|
+
event.payload.providerSession.resumeOutcome === "resumed")
|
|
171
|
+
original.phase = "answered";
|
|
172
|
+
yield event;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
if (original.phase === "submitting")
|
|
177
|
+
original.phase = "unknown";
|
|
178
|
+
}
|
|
179
|
+
})();
|
|
180
|
+
return { route: "new_run", input: structuredClone(input), events };
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
if (original.phase === "submitting")
|
|
184
|
+
original.phase = attempted ? "unknown" : "pending";
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
#assertPending() {
|
|
189
|
+
const snapshot = this.#snapshot;
|
|
190
|
+
if (snapshot.phase !== "pending")
|
|
191
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
192
|
+
this.#assertNotExpired();
|
|
193
|
+
}
|
|
194
|
+
#assertNotExpired() {
|
|
195
|
+
const expiresAt = this.#snapshot.question.expiresAt;
|
|
196
|
+
if (expiresAt !== undefined && Date.parse(expiresAt) <= Date.now())
|
|
197
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createInputInvoke, assertInvokeRequestSize, identifyInvokeInput, assertHostFrameIdentity, isHostTerminal, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError } from "@mininglamp-oss/octo-runtime-protocol";
|
|
1
|
+
import { createInputInvoke, assertInvokeRequestSize, identifyInvokeInput, assertHostFrameIdentity, isHostTerminal, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError, protocolError } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
2
|
const TTL = 120_000;
|
|
3
3
|
/**
|
|
4
4
|
* Kernel 内唯一的 Run 事件源:从 worker 消费一次,按原 stream/seq 有界缓存供多个订阅观察。
|
|
@@ -261,7 +261,7 @@ export class HostRunService {
|
|
|
261
261
|
respond(runId, response) {
|
|
262
262
|
const run = this.#get(runId);
|
|
263
263
|
if (run.terminal)
|
|
264
|
-
throw
|
|
264
|
+
throw protocolError("INTERACTION_NOT_ACTIVE", "INTERACTION_EXPIRED");
|
|
265
265
|
return this.respondInteraction(run.invocationId, response);
|
|
266
266
|
}
|
|
267
267
|
respondNativeRun(runId, response) {
|
|
@@ -3,6 +3,7 @@ export { HostRunService } from "./host-run-service.js";
|
|
|
3
3
|
export { createKernelService, type KernelService, type KernelServiceOptions, type KernelServiceStatus } from "./service.js";
|
|
4
4
|
export * from "./lifecycle.js";
|
|
5
5
|
export { attachKernel } from "./client.js";
|
|
6
|
+
export { AsyncQuestionReply, type AsyncQuestionReplyResult } from "./async-question-reply.js";
|
|
6
7
|
export { isInvocationNotSubmitted } from "./submission-error.js";
|
|
7
8
|
export * from "./types.js";
|
|
8
9
|
export { InvocationManifest, acknowledgeOrphanCleanup, inspectOrphanCleanup, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
|
|
@@ -4,6 +4,7 @@ export { HostRunService } from "./host-run-service.js";
|
|
|
4
4
|
export { createKernelService } from "./service.js";
|
|
5
5
|
export * from "./lifecycle.js";
|
|
6
6
|
export { attachKernel } from "./client.js";
|
|
7
|
+
export { AsyncQuestionReply } from "./async-question-reply.js";
|
|
7
8
|
export { isInvocationNotSubmitted } from "./submission-error.js";
|
|
8
9
|
export * from "./types.js";
|
|
9
10
|
export { InvocationManifest, acknowledgeOrphanCleanup, inspectOrphanCleanup, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
|
|
@@ -59,4 +59,6 @@ export declare class WorkerRpcClient implements WorkerRpc {
|
|
|
59
59
|
/** Await the invoke ACK first, then keep yielding this invocation's event notifications until done. */
|
|
60
60
|
invokeFrames(input: InvokeInput, environment?: InvokeEnvironment): AsyncGenerator<HostFrame>;
|
|
61
61
|
}
|
|
62
|
+
/** Kernel 配置与 worker 探测共用的配置形态校验;不修改调用方对象。 */
|
|
63
|
+
export declare function probeOptions(value: unknown): AdapterProbeOptions | undefined;
|
|
62
64
|
export {};
|
|
@@ -272,7 +272,15 @@ export class WorkerRpcServer {
|
|
|
272
272
|
code: errorCode(error),
|
|
273
273
|
message: errorMessage(error),
|
|
274
274
|
...(isRecord(error) && typeof error.code === "string"
|
|
275
|
-
? {
|
|
275
|
+
? {
|
|
276
|
+
data: {
|
|
277
|
+
code: error.code,
|
|
278
|
+
...(error.code === "ASYNC_ANSWER_REJECTED" &&
|
|
279
|
+
Number.isSafeInteger(error.providerRpcCode)
|
|
280
|
+
? { providerRpcCode: error.providerRpcCode }
|
|
281
|
+
: {})
|
|
282
|
+
}
|
|
283
|
+
}
|
|
276
284
|
: {})
|
|
277
285
|
}
|
|
278
286
|
});
|
|
@@ -433,7 +441,11 @@ export class WorkerRpcClient {
|
|
|
433
441
|
this.#pending.delete(message.id);
|
|
434
442
|
if (message.error)
|
|
435
443
|
pending.reject(Object.assign(new Error(message.error.message), {
|
|
436
|
-
code: message.error.data?.code ?? message.error.code
|
|
444
|
+
code: message.error.data?.code ?? message.error.code,
|
|
445
|
+
...(message.error.data?.code === "ASYNC_ANSWER_REJECTED" &&
|
|
446
|
+
Number.isSafeInteger(message.error.data.providerRpcCode)
|
|
447
|
+
? { providerRpcCode: message.error.data.providerRpcCode }
|
|
448
|
+
: {})
|
|
437
449
|
}));
|
|
438
450
|
else
|
|
439
451
|
pending.resolve(message.result);
|
|
@@ -633,7 +645,8 @@ function traceFrame(message, raw) {
|
|
|
633
645
|
bytes: Buffer.byteLength(raw)
|
|
634
646
|
});
|
|
635
647
|
}
|
|
636
|
-
|
|
648
|
+
/** Kernel 配置与 worker 探测共用的配置形态校验;不修改调用方对象。 */
|
|
649
|
+
export function probeOptions(value) {
|
|
637
650
|
if (value === undefined)
|
|
638
651
|
return undefined;
|
|
639
652
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -3,9 +3,10 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { chmod, mkdir, rm } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { readBoundedLines, RuntimeLogging, assertRuntimeLogging } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
6
|
-
import { assertHostRunReceipt, createInputInvoke, contextItem, INVOKE_REQUEST_MAX_BYTES, HOST_RPC_MAX_LINE_BYTES } from "@mininglamp-oss/octo-runtime-protocol";
|
|
6
|
+
import { assertHostRunReceipt, createInputInvoke, contextItem, INVOKE_REQUEST_MAX_BYTES, HOST_RPC_MAX_LINE_BYTES, resolveStreamLimitPolicy } from "@mininglamp-oss/octo-runtime-protocol";
|
|
7
7
|
import { HostRunService } from "./host-run-service.js";
|
|
8
8
|
import { WorkerSupervisor } from "./supervisor.js";
|
|
9
|
+
import { probeOptions } from "./rpc.js";
|
|
9
10
|
import { acquireEndpoint } from "./endpoint.js";
|
|
10
11
|
import { InvocationManifest } from "./invocation-manifest.js";
|
|
11
12
|
import { readModuleManifest, resolveAdapterModules } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
@@ -83,9 +84,15 @@ export async function startKernelServer(options, signal) {
|
|
|
83
84
|
const logging = new RuntimeLogging(options.logging);
|
|
84
85
|
let manifest;
|
|
85
86
|
const worker = new WorkerSupervisor({ entrypoint: options.workerEntrypoint, adapterModules, env: options.env }, (pid) => manifest?.setWorker(pid, options.workerEntrypoint) ?? Promise.resolve(), logging.kernel);
|
|
87
|
+
// 每轮只读取一次宿主配置;复制后冻结自有快照,不冻结宿主持有的原对象。
|
|
86
88
|
const configure = (input) => {
|
|
87
89
|
const type = contextItem(input.contexts, "octo.execution", "adapter")?.payload.type;
|
|
88
|
-
|
|
90
|
+
const config = probeOptions((options.configurations?.(typeof input.runMetadata?.runtimeId === "string" ? input.runMetadata.runtimeId : undefined) ?? options.adapterConfigurations)?.[typeof type === "string" ? type : "codex"]);
|
|
91
|
+
return (config &&
|
|
92
|
+
Object.freeze({
|
|
93
|
+
providerOptions: config.providerOptions && Object.freeze({ ...config.providerOptions }),
|
|
94
|
+
streamLimits: resolveStreamLimitPolicy(config.streamLimits)
|
|
95
|
+
}));
|
|
89
96
|
};
|
|
90
97
|
const transport = {
|
|
91
98
|
list: (configs) => worker.client.list(configs ?? options.configurations?.() ?? options.adapterConfigurations),
|
|
@@ -94,23 +101,9 @@ export async function startKernelServer(options, signal) {
|
|
|
94
101
|
respondInteraction: (id, response) => worker.client.respondInteraction(id, response),
|
|
95
102
|
respondNative: (id, response) => worker.client.respondNative(id, response),
|
|
96
103
|
invoke: createInputInvoke((input, environment) => transport.invokeFrames(input, environment)),
|
|
97
|
-
|
|
98
|
-
const config = configure(input);
|
|
99
|
-
yield* worker.client.invokeFrames(config
|
|
100
|
-
? {
|
|
101
|
-
...input,
|
|
102
|
-
agentConfig: {
|
|
103
|
-
...input.agentConfig,
|
|
104
|
-
providerOptions: {
|
|
105
|
-
...input.agentConfig?.providerOptions,
|
|
106
|
-
...config.providerOptions
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
: input, environment);
|
|
111
|
-
}
|
|
104
|
+
invokeFrames: (input, environment) => worker.client.invokeFrames(input, environment)
|
|
112
105
|
};
|
|
113
|
-
const runs = new HostRunService(transport
|
|
106
|
+
const runs = new HostRunService(transport);
|
|
114
107
|
const sockets = new Set();
|
|
115
108
|
let closing;
|
|
116
109
|
let listening = false;
|
|
@@ -194,7 +187,23 @@ export async function startKernelServer(options, signal) {
|
|
|
194
187
|
throw new KernelError(worker.status.state === "exhausted"
|
|
195
188
|
? "WORKER_RESTART_EXHAUSTED"
|
|
196
189
|
: "KERNEL_UNAVAILABLE", { invocation_not_submitted: true });
|
|
197
|
-
const
|
|
190
|
+
const input = params.input;
|
|
191
|
+
const config = configure(input);
|
|
192
|
+
// 选项先合并再进入 HostRunService 的整请求预算检查;策略沿同一调用传给 worker 和重放窗口。
|
|
193
|
+
const configuredInput = config
|
|
194
|
+
? {
|
|
195
|
+
...input,
|
|
196
|
+
agentConfig: {
|
|
197
|
+
...input.agentConfig,
|
|
198
|
+
providerOptions: {
|
|
199
|
+
...input.agentConfig?.providerOptions,
|
|
200
|
+
...config.providerOptions
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
: input;
|
|
205
|
+
const receipt = await runs.submit(configuredInput, {
|
|
206
|
+
streamLimits: config?.streamLimits,
|
|
198
207
|
executionEnvOverrides: params.executionEnvOverrides
|
|
199
208
|
});
|
|
200
209
|
result = { kernel_instance_id: instance, receipt };
|
|
@@ -300,6 +309,12 @@ export async function startKernelServer(options, signal) {
|
|
|
300
309
|
message: "Kernel request failed",
|
|
301
310
|
data: {
|
|
302
311
|
code,
|
|
312
|
+
// worker RPC 已还原 camelCase 属性;此处转换为公开 socket 协议字段,client 保留整个 data。
|
|
313
|
+
...(code === "ASYNC_ANSWER_REJECTED" &&
|
|
314
|
+
record(error) &&
|
|
315
|
+
Number.isSafeInteger(error.providerRpcCode)
|
|
316
|
+
? { provider_rpc_code: error.providerRpcCode }
|
|
317
|
+
: {}),
|
|
303
318
|
...(error instanceof KernelError &&
|
|
304
319
|
error.data?.invocation_not_submitted === true
|
|
305
320
|
? { invocation_not_submitted: true, kernel_instance_id: instance }
|
|
@@ -418,6 +433,8 @@ function record(value) {
|
|
|
418
433
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
419
434
|
}
|
|
420
435
|
function safeCode(error) {
|
|
436
|
+
if (record(error) && typeof error.code === "string" && /^[A-Z][A-Z0-9_]{1,80}$/.test(error.code))
|
|
437
|
+
return error.code;
|
|
421
438
|
return error instanceof Error && /^[A-Z][A-Z0-9_]{1,80}$/.test(error.message)
|
|
422
439
|
? error.message
|
|
423
440
|
: "KERNEL_REQUEST_FAILED";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-executor-kernel",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
22
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
21
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.9",
|
|
22
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9",
|
|
23
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.9"
|
|
24
24
|
},
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"files": [
|