@mininglamp-oss/octo-runtime 1.1.8 → 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/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 +6 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +2 -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/channel.js +4 -0
- 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/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/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-B127MhT-.js → index-BVxePruX.js} +1 -1
- 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
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { assertAsyncQuestions, assertQuestionRequest, questionAnswerText, protocolError } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
const failure = (code) => Object.assign(new Error(code), { code });
|
|
4
|
+
const digest = (value) => createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
5
|
+
/** 保留原生异步快照;不从正文推断问题,也不授权回答历史消息。 */
|
|
6
|
+
export function asyncQuestionMetadata(item) {
|
|
7
|
+
if (item.delivery !== "async")
|
|
8
|
+
return {};
|
|
9
|
+
if (item.questions === null || item.questions === undefined)
|
|
10
|
+
return { delivery: "async" };
|
|
11
|
+
if (!Array.isArray(item.questions))
|
|
12
|
+
throw failure("INVALID_ASYNC_QUESTIONS");
|
|
13
|
+
const questions = item.questions.map((value) => {
|
|
14
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
15
|
+
throw failure("INVALID_ASYNC_QUESTIONS");
|
|
16
|
+
const q = value;
|
|
17
|
+
return { title: q.title, options: q.options };
|
|
18
|
+
});
|
|
19
|
+
assertAsyncQuestions(questions);
|
|
20
|
+
return { delivery: "async", questions };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* invocation 独享有界状态;transport 在读取成功 RPC 帧时同步调用 accept,
|
|
24
|
+
* 避免同一缓冲区的后续 turn/completed 覆盖已经观察到的接纳事实。
|
|
25
|
+
*/
|
|
26
|
+
export class CodexAsyncQuestions {
|
|
27
|
+
invocationId;
|
|
28
|
+
emit;
|
|
29
|
+
send;
|
|
30
|
+
now;
|
|
31
|
+
lifetimeMs;
|
|
32
|
+
#pending = new Map();
|
|
33
|
+
#seen = new Map();
|
|
34
|
+
constructor(invocationId, emit, send, now = Date.now, lifetimeMs = Infinity) {
|
|
35
|
+
this.invocationId = invocationId;
|
|
36
|
+
this.emit = emit;
|
|
37
|
+
this.send = send;
|
|
38
|
+
this.now = now;
|
|
39
|
+
this.lifetimeMs = lifetimeMs;
|
|
40
|
+
}
|
|
41
|
+
get size() {
|
|
42
|
+
return this.#pending.size;
|
|
43
|
+
}
|
|
44
|
+
register(item, threadId, turnId, otherPending) {
|
|
45
|
+
const { questions } = asyncQuestionMetadata(item);
|
|
46
|
+
if (!questions?.length)
|
|
47
|
+
return;
|
|
48
|
+
if (typeof item.id !== "string" || !item.id)
|
|
49
|
+
throw failure("INVALID_ASYNC_QUESTION_ID");
|
|
50
|
+
const id = `codex:async:${digest([this.invocationId, threadId, turnId, item.id])}`;
|
|
51
|
+
const hash = digest(questions);
|
|
52
|
+
const previous = this.#seen.get(id);
|
|
53
|
+
if (previous !== undefined) {
|
|
54
|
+
if (previous !== hash)
|
|
55
|
+
throw failure("ASYNC_QUESTION_CONFLICT");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (this.#seen.size >= 1024 || this.size + otherPending >= 16)
|
|
59
|
+
throw failure("INTERACTION_PENDING_LIMIT_EXCEEDED");
|
|
60
|
+
const request = {
|
|
61
|
+
schema: "octo.question-request/v1",
|
|
62
|
+
messageId: item.id,
|
|
63
|
+
questions: questions.map((q, index) => ({ ...q, id: `q:${index}`, allowCustom: true }))
|
|
64
|
+
};
|
|
65
|
+
assertQuestionRequest(request);
|
|
66
|
+
const expiresAt = this.now() + this.lifetimeMs;
|
|
67
|
+
const timer = Number.isFinite(expiresAt)
|
|
68
|
+
? setTimeout(() => this.#finish(id, "expired", "question_timeout"), this.lifetimeMs)
|
|
69
|
+
: undefined;
|
|
70
|
+
timer?.unref?.();
|
|
71
|
+
this.#seen.set(id, hash);
|
|
72
|
+
// 直接 Core 消费端持有公开事件对象;独立保存原题,避免 UI 修改展示数据后改写投递关联。
|
|
73
|
+
this.#pending.set(id, {
|
|
74
|
+
request: structuredClone(request),
|
|
75
|
+
threadId,
|
|
76
|
+
turnId,
|
|
77
|
+
expiresAt,
|
|
78
|
+
timer,
|
|
79
|
+
submitting: false
|
|
80
|
+
});
|
|
81
|
+
this.emit({
|
|
82
|
+
protocolVersion: 2,
|
|
83
|
+
type: "interaction.requested",
|
|
84
|
+
payload: {
|
|
85
|
+
interactionId: id,
|
|
86
|
+
executionInstanceId: this.invocationId,
|
|
87
|
+
kind: "question",
|
|
88
|
+
delivery: "async",
|
|
89
|
+
...(Number.isFinite(expiresAt) ? { expiresAt: new Date(expiresAt).toISOString() } : {}),
|
|
90
|
+
request: request
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/** 提交只允许一个在途请求;取消仅关闭表单,不向 Provider 伪造答案。 */
|
|
95
|
+
respond(response) {
|
|
96
|
+
const id = response.interactionId;
|
|
97
|
+
const batch = this.#pending.get(id);
|
|
98
|
+
if (!batch || batch.submitting)
|
|
99
|
+
return Promise.reject(protocolError("INTERACTION_NOT_ACTIVE"));
|
|
100
|
+
if (batch.expiresAt <= this.now()) {
|
|
101
|
+
this.#finish(id, "expired", "question_timeout");
|
|
102
|
+
return Promise.reject(protocolError("INTERACTION_NOT_ACTIVE"));
|
|
103
|
+
}
|
|
104
|
+
if (response.outcome === "cancelled" && response.value === undefined) {
|
|
105
|
+
this.#finish(id, "resolved", "user_cancelled", "cancelled");
|
|
106
|
+
return Promise.resolve();
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
if (response.outcome !== "answered")
|
|
110
|
+
throw failure("INVALID_QUESTION_RESPONSE");
|
|
111
|
+
const text = questionAnswerText(batch.request, response.value);
|
|
112
|
+
batch.submitting = true;
|
|
113
|
+
clearTimeout(batch.timer);
|
|
114
|
+
const hex = digest(id);
|
|
115
|
+
const clientId = `${hex.slice(0, 8)}-${hex.slice(8, 12)}-5${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
116
|
+
const params = {
|
|
117
|
+
threadId: batch.threadId,
|
|
118
|
+
expectedTurnId: batch.turnId,
|
|
119
|
+
clientUserMessageId: clientId,
|
|
120
|
+
input: [
|
|
121
|
+
{
|
|
122
|
+
type: "text",
|
|
123
|
+
text,
|
|
124
|
+
text_elements: []
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
batch.reject = reject;
|
|
130
|
+
const failed = (error) => {
|
|
131
|
+
if (!this.#pending.has(id))
|
|
132
|
+
return;
|
|
133
|
+
const explicit = error.name === "CodexAppServerRpcError";
|
|
134
|
+
if (error.deliveryNotAttempted === true) {
|
|
135
|
+
batch.submitting = false;
|
|
136
|
+
batch.reject = undefined;
|
|
137
|
+
batch.timer = Number.isFinite(batch.expiresAt)
|
|
138
|
+
? setTimeout(() => this.#finish(id, "expired", "question_timeout"), Math.max(0, batch.expiresAt - this.now()))
|
|
139
|
+
: undefined;
|
|
140
|
+
batch.timer?.unref?.();
|
|
141
|
+
reject(error);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this.#finish(id, "invalidated", explicit ? "provider_rejected" : "submission_outcome_unknown");
|
|
145
|
+
const result = failure(explicit ? "ASYNC_ANSWER_REJECTED" : "OPERATION_OUTCOME_UNKNOWN");
|
|
146
|
+
// RPC 错误码可跨 worker 诊断;不把 Provider 的任意正文复制到公共错误。
|
|
147
|
+
const nativeCode = error.code;
|
|
148
|
+
reject(Object.assign(result, {
|
|
149
|
+
cause: error,
|
|
150
|
+
...(explicit && typeof nativeCode === "number" ? { providerRpcCode: nativeCode } : {})
|
|
151
|
+
}));
|
|
152
|
+
};
|
|
153
|
+
try {
|
|
154
|
+
void this.send(params, (value) => {
|
|
155
|
+
if (!this.#pending.has(id) ||
|
|
156
|
+
!value ||
|
|
157
|
+
typeof value !== "object" ||
|
|
158
|
+
value.turnId !== batch.turnId)
|
|
159
|
+
throw failure("OPERATION_OUTCOME_UNKNOWN");
|
|
160
|
+
this.#finish(id, "resolved", "provider_accepted", "answered");
|
|
161
|
+
resolve();
|
|
162
|
+
}, failed).catch(failed);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
failed(error instanceof Error ? error : new Error(String(error)));
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
return Promise.reject(error instanceof Error ? error : new Error(String(error)));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/** 正常完成仅释放未答旁路;宿主可续跑。已发出未确认的答案仍为未知,不得重投。 */
|
|
174
|
+
invalidate(reason) {
|
|
175
|
+
for (const [id, batch] of this.#pending) {
|
|
176
|
+
if (reason === "run_completed" && !batch.submitting) {
|
|
177
|
+
clearTimeout(batch.timer);
|
|
178
|
+
this.#pending.delete(id);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const reject = batch.reject;
|
|
182
|
+
this.#finish(id, "invalidated", batch.submitting ? "submission_outcome_unknown" : reason);
|
|
183
|
+
reject?.(failure("OPERATION_OUTCOME_UNKNOWN"));
|
|
184
|
+
}
|
|
185
|
+
this.#seen.clear();
|
|
186
|
+
}
|
|
187
|
+
#finish(id, status, reasonCode, outcome) {
|
|
188
|
+
const batch = this.#pending.get(id);
|
|
189
|
+
if (!batch)
|
|
190
|
+
return;
|
|
191
|
+
clearTimeout(batch.timer);
|
|
192
|
+
this.#pending.delete(id);
|
|
193
|
+
this.emit({
|
|
194
|
+
protocolVersion: 2,
|
|
195
|
+
type: "interaction.resolved",
|
|
196
|
+
payload: {
|
|
197
|
+
interactionId: id,
|
|
198
|
+
executionInstanceId: this.invocationId,
|
|
199
|
+
status,
|
|
200
|
+
reasonCode,
|
|
201
|
+
...(outcome ? { outcome } : {})
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Writable } from "node:stream";
|
|
2
|
+
/** 本地传输原因独立于 Provider 返回的 RPC 错误,不能用 stderr 推断认证状态。 */
|
|
3
|
+
export declare function codexTransportError(code: string, cause?: unknown): Error;
|
|
4
|
+
/**
|
|
5
|
+
* 每个 app-server 独占的 stdin 发送器。写回调仅确认本地写入,不能证明命令执行。
|
|
6
|
+
* 所有普通 RPC/回复共用 FIFO;控制预留只用于拒绝与中断,仍遵守 Writable 背压。
|
|
7
|
+
* stop 结算所有等待并解除监听;已交给 Writable 的字节无法撤回或安全重试。
|
|
8
|
+
*/
|
|
9
|
+
export declare class CodexStdinWriter {
|
|
10
|
+
#private;
|
|
11
|
+
readonly output: Writable;
|
|
12
|
+
readonly onFailure: (error: Error) => void;
|
|
13
|
+
constructor(output: Writable, onFailure: (error: Error) => void, limits?: {
|
|
14
|
+
maxItems?: number;
|
|
15
|
+
maxBytes?: number;
|
|
16
|
+
controlItems?: number;
|
|
17
|
+
controlBytes?: number;
|
|
18
|
+
stallMs?: number;
|
|
19
|
+
deliveryMs?: number;
|
|
20
|
+
});
|
|
21
|
+
/** 入队同步冻结序列化行;返回的取消函数只删除未写出的条目,不重发在途字节。 */
|
|
22
|
+
write(message: Record<string, unknown>, onError: (error: Error) => void, onWritten?: () => void, options?: {
|
|
23
|
+
control?: boolean;
|
|
24
|
+
timeoutMs?: number;
|
|
25
|
+
}): () => void;
|
|
26
|
+
/** 终态先撤销未送达决定,再 best-effort 中断;不能等 drain 才处理取消。 */
|
|
27
|
+
cancelPending(error: Error): void;
|
|
28
|
+
/** 所有者关闭时只结算资源;不额外制造新的执行失败。 */
|
|
29
|
+
stop(error: Error): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { performance } from "node:perf_hooks";
|
|
2
|
+
/** 本地传输原因独立于 Provider 返回的 RPC 错误,不能用 stderr 推断认证状态。 */
|
|
3
|
+
export function codexTransportError(code, cause) {
|
|
4
|
+
return Object.assign(new Error(cause instanceof Error ? `${code}: ${cause.message}` : code, cause === undefined ? undefined : { cause }), { code });
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 每个 app-server 独占的 stdin 发送器。写回调仅确认本地写入,不能证明命令执行。
|
|
8
|
+
* 所有普通 RPC/回复共用 FIFO;控制预留只用于拒绝与中断,仍遵守 Writable 背压。
|
|
9
|
+
* stop 结算所有等待并解除监听;已交给 Writable 的字节无法撤回或安全重试。
|
|
10
|
+
*/
|
|
11
|
+
export class CodexStdinWriter {
|
|
12
|
+
output;
|
|
13
|
+
onFailure;
|
|
14
|
+
#normal = [];
|
|
15
|
+
#control = [];
|
|
16
|
+
#active;
|
|
17
|
+
#failure;
|
|
18
|
+
#admissionError;
|
|
19
|
+
#timer;
|
|
20
|
+
#scheduled = false;
|
|
21
|
+
#lastProgress = performance.now();
|
|
22
|
+
#limits;
|
|
23
|
+
constructor(output, onFailure, limits = {}) {
|
|
24
|
+
this.output = output;
|
|
25
|
+
this.onFailure = onFailure;
|
|
26
|
+
this.#limits = {
|
|
27
|
+
maxItems: 4096,
|
|
28
|
+
maxBytes: 64 * 1024 * 1024,
|
|
29
|
+
controlItems: 8,
|
|
30
|
+
controlBytes: 64 * 1024,
|
|
31
|
+
stallMs: 5000,
|
|
32
|
+
deliveryMs: 30_000,
|
|
33
|
+
...limits
|
|
34
|
+
};
|
|
35
|
+
for (const value of Object.values(this.#limits))
|
|
36
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
37
|
+
throw new Error("Invalid stdin writer limit");
|
|
38
|
+
output.on("drain", this.#drain);
|
|
39
|
+
output.on("error", this.#error);
|
|
40
|
+
output.on("close", this.#closed);
|
|
41
|
+
}
|
|
42
|
+
/** 入队同步冻结序列化行;返回的取消函数只删除未写出的条目,不重发在途字节。 */
|
|
43
|
+
write(message, onError, onWritten, options = {}) {
|
|
44
|
+
const denied = this.#failure ?? (!options.control ? this.#admissionError : undefined);
|
|
45
|
+
if (denied) {
|
|
46
|
+
onError(denied);
|
|
47
|
+
return () => { };
|
|
48
|
+
}
|
|
49
|
+
let line;
|
|
50
|
+
try {
|
|
51
|
+
line = `${JSON.stringify(message)}\n`;
|
|
52
|
+
}
|
|
53
|
+
catch (cause) {
|
|
54
|
+
const error = codexTransportError("CODEX_STDIN_WRITE_FAILED", cause);
|
|
55
|
+
this.#fail(error);
|
|
56
|
+
onError(error);
|
|
57
|
+
return () => { };
|
|
58
|
+
}
|
|
59
|
+
const control = options.control === true;
|
|
60
|
+
const entries = [...(control ? this.#control : this.#normal)];
|
|
61
|
+
if (this.#active?.control === control)
|
|
62
|
+
entries.push(this.#active);
|
|
63
|
+
const bytes = Buffer.byteLength(line);
|
|
64
|
+
const code = entries.length >= (control ? this.#limits.controlItems : this.#limits.maxItems)
|
|
65
|
+
? "CODEX_STDIN_QUEUE_ITEMS_EXCEEDED"
|
|
66
|
+
: entries.reduce((sum, entry) => sum + entry.bytes, bytes) >
|
|
67
|
+
(control ? this.#limits.controlBytes : this.#limits.maxBytes)
|
|
68
|
+
? "CODEX_STDIN_QUEUE_BYTES_EXCEEDED"
|
|
69
|
+
: undefined;
|
|
70
|
+
if (code) {
|
|
71
|
+
const error = codexTransportError(code);
|
|
72
|
+
this.#fail(error);
|
|
73
|
+
onError(error);
|
|
74
|
+
return () => { };
|
|
75
|
+
}
|
|
76
|
+
if (!this.#active && !this.#normal.length && !this.#control.length)
|
|
77
|
+
this.#lastProgress = performance.now();
|
|
78
|
+
const entry = {
|
|
79
|
+
line,
|
|
80
|
+
bytes,
|
|
81
|
+
control,
|
|
82
|
+
deadline: performance.now() + Math.min(options.timeoutMs ?? Infinity, this.#limits.deliveryMs),
|
|
83
|
+
onError,
|
|
84
|
+
onWritten,
|
|
85
|
+
settled: false,
|
|
86
|
+
callbackDone: false,
|
|
87
|
+
needsDrain: false,
|
|
88
|
+
drained: false
|
|
89
|
+
};
|
|
90
|
+
(control ? this.#control : this.#normal).push(entry);
|
|
91
|
+
this.#schedule();
|
|
92
|
+
this.#arm();
|
|
93
|
+
return () => {
|
|
94
|
+
const queue = control ? this.#control : this.#normal;
|
|
95
|
+
const index = queue.indexOf(entry);
|
|
96
|
+
if (index < 0)
|
|
97
|
+
return;
|
|
98
|
+
queue.splice(index, 1);
|
|
99
|
+
// RPC 所有者已经结算超时,删除条目不能再次调用它的错误回调。
|
|
100
|
+
entry.settled = true;
|
|
101
|
+
this.#arm();
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** 终态先撤销未送达决定,再 best-effort 中断;不能等 drain 才处理取消。 */
|
|
105
|
+
cancelPending(error) {
|
|
106
|
+
this.#admissionError ??= error;
|
|
107
|
+
const entries = [...this.#normal.splice(0), ...this.#control.splice(0)];
|
|
108
|
+
if (this.#active)
|
|
109
|
+
entries.push(this.#active);
|
|
110
|
+
for (const entry of entries)
|
|
111
|
+
this.#reject(entry, error);
|
|
112
|
+
this.#arm();
|
|
113
|
+
}
|
|
114
|
+
/** 所有者关闭时只结算资源;不额外制造新的执行失败。 */
|
|
115
|
+
stop(error) {
|
|
116
|
+
if (this.#failure)
|
|
117
|
+
return;
|
|
118
|
+
this.#failure = error;
|
|
119
|
+
clearTimeout(this.#timer);
|
|
120
|
+
this.output.off("drain", this.#drain);
|
|
121
|
+
this.output.off("error", this.#error);
|
|
122
|
+
this.output.off("close", this.#closed);
|
|
123
|
+
const entries = [...this.#normal.splice(0), ...this.#control.splice(0)];
|
|
124
|
+
if (this.#active)
|
|
125
|
+
entries.push(this.#active);
|
|
126
|
+
this.#active = undefined;
|
|
127
|
+
for (const entry of entries)
|
|
128
|
+
this.#reject(entry, error);
|
|
129
|
+
}
|
|
130
|
+
#reject(entry, error) {
|
|
131
|
+
if (entry.settled)
|
|
132
|
+
return;
|
|
133
|
+
entry.settled = true;
|
|
134
|
+
entry.onError(error);
|
|
135
|
+
}
|
|
136
|
+
#fail(error) {
|
|
137
|
+
if (this.#failure)
|
|
138
|
+
return;
|
|
139
|
+
this.stop(error);
|
|
140
|
+
this.onFailure(error);
|
|
141
|
+
}
|
|
142
|
+
#error = (cause) => this.#fail(codexTransportError("CODEX_STDIN_WRITE_FAILED", cause));
|
|
143
|
+
#closed = () => this.#fail(codexTransportError("CODEX_TRANSPORT_FAILED"));
|
|
144
|
+
#drain = () => {
|
|
145
|
+
if (!this.#active || this.#active.drained)
|
|
146
|
+
return;
|
|
147
|
+
this.#active.drained = true;
|
|
148
|
+
this.#lastProgress = performance.now();
|
|
149
|
+
this.#schedule();
|
|
150
|
+
};
|
|
151
|
+
#schedule() {
|
|
152
|
+
if (this.#scheduled || this.#failure)
|
|
153
|
+
return;
|
|
154
|
+
this.#scheduled = true;
|
|
155
|
+
queueMicrotask(() => {
|
|
156
|
+
this.#scheduled = false;
|
|
157
|
+
this.#pump();
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
#pump() {
|
|
161
|
+
if (this.#failure)
|
|
162
|
+
return;
|
|
163
|
+
if (this.#active) {
|
|
164
|
+
if (!this.#active.callbackDone || (this.#active.needsDrain && !this.#active.drained)) {
|
|
165
|
+
this.#arm();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.#active = undefined;
|
|
169
|
+
}
|
|
170
|
+
const entry = this.#control.shift() ?? this.#normal.shift();
|
|
171
|
+
if (!entry) {
|
|
172
|
+
this.#arm();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.#active = entry;
|
|
176
|
+
if (entry.deadline <= performance.now()) {
|
|
177
|
+
this.#fail(codexTransportError("CODEX_STDIN_DELIVERY_TIMEOUT"));
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
// 先登记 active,再调用 write;同步回调/提前 drain 也必须看到同一条记录。
|
|
182
|
+
entry.needsDrain = !this.output.write(entry.line, (cause) => {
|
|
183
|
+
if (this.#failure || this.#active !== entry)
|
|
184
|
+
return;
|
|
185
|
+
if (cause) {
|
|
186
|
+
this.#error(cause);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
entry.callbackDone = true;
|
|
190
|
+
this.#lastProgress = performance.now();
|
|
191
|
+
if (!entry.settled) {
|
|
192
|
+
entry.settled = true;
|
|
193
|
+
entry.onWritten?.();
|
|
194
|
+
}
|
|
195
|
+
this.#schedule();
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
catch (cause) {
|
|
199
|
+
this.#error(cause instanceof Error ? cause : new Error(String(cause)));
|
|
200
|
+
}
|
|
201
|
+
this.#arm();
|
|
202
|
+
}
|
|
203
|
+
#arm() {
|
|
204
|
+
clearTimeout(this.#timer);
|
|
205
|
+
if (this.#failure)
|
|
206
|
+
return;
|
|
207
|
+
const entries = [...this.#normal, ...this.#control];
|
|
208
|
+
if (this.#active)
|
|
209
|
+
entries.push(this.#active);
|
|
210
|
+
if (!entries.length)
|
|
211
|
+
return;
|
|
212
|
+
const delivery = Math.min(...entries.map((entry) => entry.deadline));
|
|
213
|
+
const stall = this.#lastProgress + this.#limits.stallMs;
|
|
214
|
+
this.#timer = setTimeout(() => {
|
|
215
|
+
if (performance.now() < Math.min(delivery, stall)) {
|
|
216
|
+
this.#arm();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.#fail(codexTransportError(stall < delivery ? "CODEX_STDIN_STALLED" : "CODEX_STDIN_DELIVERY_TIMEOUT"));
|
|
220
|
+
}, Math.max(1, Math.min(delivery, stall) - performance.now()));
|
|
221
|
+
this.#timer.unref?.();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-codex",
|
|
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-protocol": "1.1.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.9"
|
|
10
10
|
},
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"files": [
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-sdk-client@0.2.1-rc.
|
|
1
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-sdk-client@0.2.1-rc.4_a87b3c368125e3b414a9622ea829ac75/node_modules/@deepseek-ai/dsh-sdk-client/lib/index.js
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
|
|
5
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-sdk-protocol@0.2.1-rc.
|
|
5
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-sdk-protocol@0.2.1-rc.4_@deepseek-ai+cordis@4.0.5_@deepseek-ai+dsh-llm_3afad2e3740a0a28b2df294ac91d0a0b/node_modules/@deepseek-ai/dsh-sdk-protocol/lib/index.js
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { StringDecoder } from "node:string_decoder";
|
|
8
8
|
var JsonRpcResponseError = class extends Error {
|
|
@@ -239,7 +239,7 @@ function abortError(reason) {
|
|
|
239
239
|
return reason instanceof Error ? reason : /* @__PURE__ */ new Error(`JSON-RPC request aborted: ${String(reason)}`);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-sdk-client@0.2.1-rc.
|
|
242
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-sdk-client@0.2.1-rc.4_a87b3c368125e3b414a9622ea829ac75/node_modules/@deepseek-ai/dsh-sdk-client/lib/index.js
|
|
243
243
|
import { existsSync, readFileSync } from "node:fs";
|
|
244
244
|
import { fileURLToPath } from "node:url";
|
|
245
245
|
function exitsWithin(child, ms) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
@deepseek-ai/dsh-sdk-client@0.2.1-rc.
|
|
2
|
-
@deepseek-ai/dsh-sdk-protocol@0.2.1-rc.
|
|
1
|
+
@deepseek-ai/dsh-sdk-client@0.2.1-rc.4
|
|
2
|
+
@deepseek-ai/dsh-sdk-protocol@0.2.1-rc.4
|
|
3
3
|
License: MIT
|
|
4
4
|
Upstream: https://github.com/deepseek-ai/deepseek-harness
|
|
5
5
|
Unmodified official npm JavaScript is bundled by esbuild.
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
resolveDshLaunch,
|
|
3
3
|
stringOption,
|
|
4
4
|
timeoutOption
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FGFEM7JP.js";
|
|
6
6
|
import {
|
|
7
7
|
DshTrajectory
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TSRZVLIG.js";
|
|
9
9
|
import {
|
|
10
10
|
DSH_MIN_VERSION,
|
|
11
11
|
DSH_VERSION,
|
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
HarnessClient,
|
|
14
14
|
dshError,
|
|
15
15
|
record
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-R3PDZLX5.js";
|
|
17
17
|
|
|
18
18
|
// packages/octo-runtime-adapter-dsh/dist/index.js
|
|
19
19
|
import { randomUUID } from "node:crypto";
|
|
20
20
|
import { realpath } from "node:fs/promises";
|
|
21
21
|
import { defineAdapter, invocationEnvironment, providerInputParts, initialControlInstructions, DriverQueue, noopRuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
22
|
-
import { contextActmode, DEFAULT_STREAM_LIMIT_POLICY } from "@mininglamp-oss/octo-runtime-protocol";
|
|
22
|
+
import { contextActmode, DEFAULT_STREAM_LIMIT_POLICY, DEFAULT_RUN_TIMEOUT_MS } from "@mininglamp-oss/octo-runtime-protocol";
|
|
23
23
|
function failureEvent(error, diagnostics) {
|
|
24
24
|
return {
|
|
25
25
|
protocolVersion: 2,
|
|
@@ -144,7 +144,7 @@ function createDshAdapter(options = {}) {
|
|
|
144
144
|
} else {
|
|
145
145
|
const initializeTimeoutMs = timeoutOption(config, "initializeTimeoutMs", 15e3);
|
|
146
146
|
const requestTimeoutMs = timeoutOption(config, "requestTimeoutMs", 3e4);
|
|
147
|
-
const runTimeoutMs = request.runtimeLimits?.runTimeoutMs ??
|
|
147
|
+
const runTimeoutMs = request.runtimeLimits?.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;
|
|
148
148
|
const shutdownTimeoutMs = timeoutOption(config, "shutdownTimeoutMs", 1e3);
|
|
149
149
|
const env = invocationEnvironment(request, {
|
|
150
150
|
DSH_PERMISSION_MODE: "danger-full-access"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-dsh",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"semver": "7.8.5",
|
|
13
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
14
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
13
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.9",
|
|
14
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-grok-build",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-acp-client": "1.1.
|
|
13
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
14
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
15
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-acp-client": "1.1.9",
|
|
13
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.9",
|
|
14
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.9",
|
|
15
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9"
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-hermes",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.9"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-kimi-code",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.9"
|
|
13
13
|
}
|
|
14
14
|
}
|