@mininglamp-oss/octo-runtime 1.1.12 → 1.1.13
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/README.md +1 -1
- package/apps/cli/dist/adapters.d.ts +19 -1
- package/apps/cli/dist/adapters.js +153 -23
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/codex.d.ts +5 -0
- package/apps/cli/dist/codex.js +36 -0
- package/apps/cli/dist/kernel.d.ts +4 -0
- package/apps/cli/dist/kernel.js +84 -0
- package/apps/cli/dist/main.js +8 -7
- package/apps/cli/dist/manifest.json +33 -22
- package/apps/cli/dist/output.d.ts +1 -0
- package/apps/cli/dist/output.js +8 -4
- package/apps/cli/dist/playboard.js +21 -12
- package/apps/cli/dist/provider-launch.d.ts +28 -0
- package/apps/cli/dist/provider-launch.js +52 -0
- package/apps/cli/dist/providers.d.ts +182 -0
- package/apps/cli/dist/providers.js +34 -0
- package/dist/public/adapter-sdk.d.ts +2 -0
- package/dist/public/adapter-sdk.js +2 -0
- package/dist/public/protocol.d.ts +1 -1
- package/dist/public/protocol.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +4 -4
- 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 +15 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +24 -28
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +10 -35
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +22 -29
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +14 -68
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +60 -43
- 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.d.ts +19 -31
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +29 -18
- 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 +6 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +32 -26
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.d.ts +54 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.js +147 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/environment.js +4 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +20 -92
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +104 -216
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.js +4 -11
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +9 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +77 -81
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +12 -14
- 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 +14 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +23 -30
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +4 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +13 -21
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +48 -26
- 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 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +15 -7
- 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 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +14 -6
- 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 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +15 -7
- 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 +7 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +27 -29
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +16 -25
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +109 -178
- 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 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +15 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +16 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +15 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +49 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +256 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/approval.js +7 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +25 -12
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +116 -58
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/mcp.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +11 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +89 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.js +25 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +10 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +19 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +153 -23
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.js +36 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.js +84 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +8 -7
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +33 -22
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +21 -12
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.d.ts +28 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.js +52 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.d.ts +182 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.js +34 -0
- 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/dist/client.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +3 -104
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +173 -1295
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +26 -54
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +13 -85
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +17 -20
- 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/browser.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +3 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.js +1 -8
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +3 -267
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +17 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +102 -396
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.js +32 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +6 -15
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +33 -178
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +11 -22
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +38 -78
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +5 -28
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +34 -37
- package/packages/octo-runtime-protocol/schema/kernel-ipc.schema.json +3 -104
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +173 -1295
- package/dist/public/codex.d.ts +0 -1
- package/dist/public/codex.js +0 -1
- package/dist/public/dsh.d.ts +0 -2
- package/dist/public/dsh.js +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +0 -1219
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +0 -5988
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +0 -56
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +0 -116
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +0 -761
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +0 -663
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +0 -191
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.d.ts +0 -12
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.js +0 -89
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.d.ts +0 -33
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.js +0 -93
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.js +0 -80
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.js +0 -9
- /package/node_modules/@mininglamp-oss/octo-runtime-client/{schema → fixtures}/kernel-ipc-fixtures.json +0 -0
- /package/packages/octo-runtime-protocol/{schema → test/fixtures}/kernel-ipc-fixtures.json +0 -0
|
@@ -4,7 +4,7 @@ import { randomUUID } from "node:crypto";
|
|
|
4
4
|
import { performance } from "node:perf_hooks";
|
|
5
5
|
import { setTimeout as delay } from "node:timers/promises";
|
|
6
6
|
import { createProcessCleanup } from "@mininglamp-oss/octo-runtime-adapter-sdk/process-cleanup";
|
|
7
|
-
import {
|
|
7
|
+
import { assertProviderCommand } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
8
8
|
import { watchLineLimit } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
9
9
|
import { DEFAULT_STREAM_LIMIT_POLICY, INVOKE_REQUEST_MAX_BYTES } from "@mininglamp-oss/octo-runtime-protocol";
|
|
10
10
|
import { CodexStdinWriter, codexTransportError } from "./stdin-writer.js";
|
|
@@ -16,6 +16,7 @@ export class CodexTurnChannel {
|
|
|
16
16
|
service;
|
|
17
17
|
incarnation;
|
|
18
18
|
allowInputEcho;
|
|
19
|
+
rawMessageMaxBytes;
|
|
19
20
|
onMessage = () => { };
|
|
20
21
|
onFailure = () => { };
|
|
21
22
|
threadId;
|
|
@@ -24,13 +25,15 @@ export class CodexTurnChannel {
|
|
|
24
25
|
closed = false;
|
|
25
26
|
startingTurn = false;
|
|
26
27
|
startingThread = false;
|
|
28
|
+
freshThread = false;
|
|
27
29
|
buffered = [];
|
|
28
30
|
bufferedBytes = 0;
|
|
29
31
|
#close;
|
|
30
|
-
constructor(service, incarnation, allowInputEcho = false) {
|
|
32
|
+
constructor(service, incarnation, allowInputEcho = false, rawMessageMaxBytes = DEFAULT_STREAM_LIMIT_POLICY.rawMessageMaxBytes) {
|
|
31
33
|
this.service = service;
|
|
32
34
|
this.incarnation = incarnation;
|
|
33
35
|
this.allowInputEcho = allowInputEcho;
|
|
36
|
+
this.rawMessageMaxBytes = rawMessageMaxBytes;
|
|
34
37
|
}
|
|
35
38
|
reserveRequestId() {
|
|
36
39
|
return this.service.reserveRequestId();
|
|
@@ -50,7 +53,7 @@ export class CodexTurnChannel {
|
|
|
50
53
|
return tail.trim() ? `${text}\n\n[codex stderr]\n${tail.trim()}` : text;
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
|
-
/**
|
|
56
|
+
/** owner 的唯一进程与关联器;多调用共享 stdio,故障替代不重放业务动作。 */
|
|
54
57
|
export class CodexService {
|
|
55
58
|
scopeId;
|
|
56
59
|
spec;
|
|
@@ -62,6 +65,7 @@ export class CodexService {
|
|
|
62
65
|
#generation = 0;
|
|
63
66
|
#nextId = 0;
|
|
64
67
|
#closing = false;
|
|
68
|
+
#recoveryStopped = false;
|
|
65
69
|
#supervision;
|
|
66
70
|
#close;
|
|
67
71
|
#failure;
|
|
@@ -72,67 +76,48 @@ export class CodexService {
|
|
|
72
76
|
#pending = new Map();
|
|
73
77
|
#channels = new Set();
|
|
74
78
|
#threads = new Map();
|
|
75
|
-
#usedThreads = new Set();
|
|
76
79
|
#serverRequests = new Map();
|
|
77
80
|
#early = new Map();
|
|
78
81
|
#earlyBytes = 0;
|
|
79
82
|
#earlyItems = 0;
|
|
80
|
-
#waiters = 0;
|
|
81
|
-
#waitingBytes = 0;
|
|
82
83
|
constructor(scopeId, spec, spawnFn = ownedSpawn, rawMessageMaxBytes = DEFAULT_STREAM_LIMIT_POLICY.rawMessageMaxBytes) {
|
|
83
84
|
this.scopeId = scopeId;
|
|
84
85
|
this.spec = spec;
|
|
85
86
|
this.spawnFn = spawnFn;
|
|
86
87
|
this.rawMessageMaxBytes = rawMessageMaxBytes;
|
|
87
88
|
}
|
|
88
|
-
/**
|
|
89
|
-
async acquire(signal,
|
|
89
|
+
/** 所有调用等待同一次启动;取消等待仅影响本调用,不取消共享启动。 */
|
|
90
|
+
async acquire(signal, allowInputEcho = false, rawMessageMaxBytes = this.rawMessageMaxBytes) {
|
|
90
91
|
if (this.#closing)
|
|
91
92
|
throw codexTransportError("CODEX_SERVICE_CLOSED");
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (++this.#waiters > 128) {
|
|
96
|
-
this.#waiters--;
|
|
97
|
-
throw codexTransportError("CODEX_SERVICE_WAITERS_EXCEEDED");
|
|
98
|
-
}
|
|
99
|
-
this.#waitingBytes += queuedBytes;
|
|
93
|
+
signal?.throwIfAborted();
|
|
94
|
+
const ready = this.#state === "ready" ? Promise.resolve() : this.#supervise(false);
|
|
95
|
+
let abort;
|
|
100
96
|
try {
|
|
101
|
-
signal
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
abort();
|
|
115
|
-
})
|
|
116
|
-
])
|
|
117
|
-
: ready);
|
|
118
|
-
}
|
|
119
|
-
finally {
|
|
120
|
-
if (abort)
|
|
121
|
-
signal?.removeEventListener("abort", abort);
|
|
122
|
-
}
|
|
123
|
-
signal?.throwIfAborted();
|
|
124
|
-
if (this.#closing || this.#state !== "ready")
|
|
125
|
-
throw codexTransportError("CODEX_SERVICE_UNAVAILABLE");
|
|
126
|
-
if (this.#channels.size >= 8)
|
|
127
|
-
throw codexTransportError("CODEX_SERVICE_TURNS_EXCEEDED");
|
|
128
|
-
const channel = new CodexTurnChannel(this, this.#generation, allowInputEcho);
|
|
129
|
-
this.#channels.add(channel);
|
|
130
|
-
return channel;
|
|
97
|
+
await (signal
|
|
98
|
+
? Promise.race([
|
|
99
|
+
ready,
|
|
100
|
+
new Promise((_, reject) => {
|
|
101
|
+
abort = () => reject(signal.reason instanceof Error
|
|
102
|
+
? signal.reason
|
|
103
|
+
: codexTransportError("CODEX_INVOCATION_CANCELLED"));
|
|
104
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
105
|
+
if (signal.aborted)
|
|
106
|
+
abort();
|
|
107
|
+
})
|
|
108
|
+
])
|
|
109
|
+
: ready);
|
|
131
110
|
}
|
|
132
111
|
finally {
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
if (abort)
|
|
113
|
+
signal?.removeEventListener("abort", abort);
|
|
135
114
|
}
|
|
115
|
+
signal?.throwIfAborted();
|
|
116
|
+
if (this.#closing || this.#state !== "ready")
|
|
117
|
+
throw codexTransportError("CODEX_SERVICE_UNAVAILABLE");
|
|
118
|
+
const channel = new CodexTurnChannel(this, this.#generation, allowInputEcho, rawMessageMaxBytes);
|
|
119
|
+
this.#channels.add(channel);
|
|
120
|
+
return channel;
|
|
136
121
|
}
|
|
137
122
|
snapshot() {
|
|
138
123
|
const current = this.#current;
|
|
@@ -174,7 +159,6 @@ export class CodexService {
|
|
|
174
159
|
const params = record(message.params);
|
|
175
160
|
try {
|
|
176
161
|
if (method === "thread/start") {
|
|
177
|
-
this.#reserveThreadHistory();
|
|
178
162
|
channel.startingThread = true;
|
|
179
163
|
}
|
|
180
164
|
if (method === "thread/resume")
|
|
@@ -202,18 +186,20 @@ export class CodexService {
|
|
|
202
186
|
const cancel = current.writer.write(message, (error) => {
|
|
203
187
|
if (method && id !== undefined)
|
|
204
188
|
this.#pending.delete(id);
|
|
189
|
+
this.#discardUnclaimedEarly();
|
|
205
190
|
onError(error);
|
|
206
191
|
}, onWritten, { ...options, owner: channel });
|
|
207
192
|
return () => {
|
|
208
193
|
cancel();
|
|
209
194
|
if (method && id !== undefined)
|
|
210
195
|
this.#pending.delete(id);
|
|
196
|
+
this.#discardUnclaimedEarly();
|
|
211
197
|
};
|
|
212
198
|
}
|
|
213
199
|
cancelPending(channel, error) {
|
|
214
200
|
this.#current?.writer.cancelOwner(channel, error);
|
|
215
201
|
}
|
|
216
|
-
/** 未确认中断/退订时保留 thread
|
|
202
|
+
/** 未确认中断/退订时保留 thread 归属,阻止迟到通知进入后续调用。 */
|
|
217
203
|
async release(channel) {
|
|
218
204
|
if (channel.closed)
|
|
219
205
|
return;
|
|
@@ -222,6 +208,7 @@ export class CodexService {
|
|
|
222
208
|
for (const [id, pending] of this.#pending)
|
|
223
209
|
if (pending.channel === channel)
|
|
224
210
|
this.#pending.delete(id);
|
|
211
|
+
this.#discardUnclaimedEarly();
|
|
225
212
|
for (const [id, owner] of this.#serverRequests)
|
|
226
213
|
if (owner === channel) {
|
|
227
214
|
this.#serverRequests.delete(id);
|
|
@@ -256,16 +243,12 @@ export class CodexService {
|
|
|
256
243
|
}
|
|
257
244
|
#forget(channel) {
|
|
258
245
|
this.#channels.delete(channel);
|
|
259
|
-
if (channel.threadId)
|
|
260
|
-
this.#usedThreads.add(channel.threadId);
|
|
261
246
|
if (channel.threadId && this.#threads.get(channel.threadId) === channel)
|
|
262
247
|
this.#threads.delete(channel.threadId);
|
|
263
248
|
}
|
|
264
249
|
#claimThread(channel, id) {
|
|
265
250
|
if (!id)
|
|
266
251
|
throw codexTransportError("CODEX_THREAD_ID_MISSING");
|
|
267
|
-
if (!this.#usedThreads.has(id) && !this.#threads.has(id))
|
|
268
|
-
this.#reserveThreadHistory(channel.startingThread ? 1 : 0);
|
|
269
252
|
const owner = this.#threads.get(id);
|
|
270
253
|
if (owner && owner !== channel)
|
|
271
254
|
throw codexTransportError("CODEX_THREAD_BUSY");
|
|
@@ -274,13 +257,6 @@ export class CodexService {
|
|
|
274
257
|
channel.threadId = id;
|
|
275
258
|
this.#threads.set(id, channel);
|
|
276
259
|
}
|
|
277
|
-
/** 发出新 thread 前预留历史槽,避免 ACK 里的容量拒绝污染健康传输。 */
|
|
278
|
-
#reserveThreadHistory(ownReservation = 0) {
|
|
279
|
-
const live = [...this.#threads.keys()].filter((id) => !this.#usedThreads.has(id)).length;
|
|
280
|
-
const starting = [...this.#channels].filter((channel) => channel.startingThread).length;
|
|
281
|
-
if (this.#usedThreads.size + live + starting - ownReservation >= 4096)
|
|
282
|
-
throw codexTransportError("CODEX_SERVICE_THREAD_HISTORY_EXCEEDED");
|
|
283
|
-
}
|
|
284
260
|
#rpc(method, params, timeoutMs = 30_000) {
|
|
285
261
|
const current = this.#current;
|
|
286
262
|
if (!current || current.failed)
|
|
@@ -317,6 +293,7 @@ export class CodexService {
|
|
|
317
293
|
const result = record(message.result);
|
|
318
294
|
const thread = record(result.thread);
|
|
319
295
|
this.#claimThread(channel, text(thread.id ?? result.threadId));
|
|
296
|
+
channel.freshThread = pending.method === "thread/start";
|
|
320
297
|
channel.startingThread = false;
|
|
321
298
|
}
|
|
322
299
|
if (pending.method === "turn/start") {
|
|
@@ -355,6 +332,7 @@ export class CodexService {
|
|
|
355
332
|
pending.reject?.(codexTransportError("CODEX_SERVICE_RPC_REJECTED"));
|
|
356
333
|
else
|
|
357
334
|
pending.resolve?.(message.result);
|
|
335
|
+
this.#discardUnclaimedEarly();
|
|
358
336
|
return;
|
|
359
337
|
}
|
|
360
338
|
const params = record(message.params);
|
|
@@ -376,6 +354,21 @@ export class CodexService {
|
|
|
376
354
|
else if (id !== undefined)
|
|
377
355
|
this.#rejectRequest(current, id, threadId ? -32000 : -32601);
|
|
378
356
|
}
|
|
357
|
+
/** 最后一个 start 已结算后,剩余通知不再有可关联的调用,不能作为历史保留。 */
|
|
358
|
+
#discardUnclaimedEarly() {
|
|
359
|
+
if (!this.#early.size ||
|
|
360
|
+
[...this.#pending.values()].some((pending) => pending.method === "thread/start"))
|
|
361
|
+
return;
|
|
362
|
+
const abandoned = [...this.#early.values()].flat();
|
|
363
|
+
this.#early.clear();
|
|
364
|
+
this.#earlyBytes = 0;
|
|
365
|
+
this.#earlyItems = 0;
|
|
366
|
+
for (const message of abandoned) {
|
|
367
|
+
const id = rpcId(message.id);
|
|
368
|
+
if (id !== undefined && this.#current && !this.#current.failed)
|
|
369
|
+
this.#rejectRequest(this.#current, id);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
379
372
|
#route(channel, message) {
|
|
380
373
|
const params = record(message.params);
|
|
381
374
|
const turnId = text(params.turnId ?? record(params.turn).id);
|
|
@@ -396,16 +389,14 @@ export class CodexService {
|
|
|
396
389
|
if (message.method === "turn/completed")
|
|
397
390
|
channel.terminal = true;
|
|
398
391
|
if (id !== undefined) {
|
|
399
|
-
//
|
|
392
|
+
// 缺少 turn ID 时,只有本调用创建的 thread 能证明归属;resume 不借助历史推断。
|
|
400
393
|
if (channel.closed ||
|
|
401
394
|
!channel.turnId ||
|
|
402
395
|
this.#serverRequests.has(id) ||
|
|
403
|
-
(!turnId &&
|
|
396
|
+
(!turnId && !channel.freshThread)) {
|
|
404
397
|
this.#rejectRequest(this.#current, id);
|
|
405
398
|
return;
|
|
406
399
|
}
|
|
407
|
-
if (this.#serverRequests.size >= 4096)
|
|
408
|
-
throw codexTransportError("CODEX_SERVICE_INTERACTIONS_EXCEEDED");
|
|
409
400
|
this.#serverRequests.set(id, channel);
|
|
410
401
|
}
|
|
411
402
|
if (!channel.closed)
|
|
@@ -434,12 +425,11 @@ export class CodexService {
|
|
|
434
425
|
}
|
|
435
426
|
this.#channels.clear();
|
|
436
427
|
this.#threads.clear();
|
|
437
|
-
this.#usedThreads.clear();
|
|
438
428
|
this.#serverRequests.clear();
|
|
439
429
|
this.#early.clear();
|
|
440
430
|
this.#earlyBytes = 0;
|
|
441
431
|
this.#earlyItems = 0;
|
|
442
|
-
if (!this.#closing) {
|
|
432
|
+
if (!this.#closing && !this.#recoveryStopped) {
|
|
443
433
|
this.#state = "recovering";
|
|
444
434
|
// The supervisor observes idle failures as well; no business invocation is needed to restart.
|
|
445
435
|
queueMicrotask(() => {
|
|
@@ -450,7 +440,7 @@ export class CodexService {
|
|
|
450
440
|
#supervise(recovery) {
|
|
451
441
|
if (this.#supervision)
|
|
452
442
|
return this.#supervision;
|
|
453
|
-
if (this.#closing)
|
|
443
|
+
if (this.#closing || this.#recoveryStopped)
|
|
454
444
|
return Promise.reject(codexTransportError("CODEX_SERVICE_CLOSED"));
|
|
455
445
|
if (this.#state === "degraded" || this.#state === "cleanup_incomplete")
|
|
456
446
|
return Promise.reject(this.#failure ?? codexTransportError("CODEX_SERVICE_DEGRADED"));
|
|
@@ -458,7 +448,7 @@ export class CodexService {
|
|
|
458
448
|
if (!this.#episodeStart)
|
|
459
449
|
this.#episodeStart = performance.now();
|
|
460
450
|
let replace = recovery || this.#generation > 0;
|
|
461
|
-
while (!this.#closing) {
|
|
451
|
+
while (!this.#closing && !this.#recoveryStopped) {
|
|
462
452
|
if (this.#current) {
|
|
463
453
|
try {
|
|
464
454
|
await this.#current.cleanup();
|
|
@@ -480,12 +470,12 @@ export class CodexService {
|
|
|
480
470
|
break;
|
|
481
471
|
}
|
|
482
472
|
}
|
|
483
|
-
if (this.#closing)
|
|
473
|
+
if (this.#closing || this.#recoveryStopped)
|
|
484
474
|
break;
|
|
485
475
|
this.#state = replace ? "recovering" : "starting";
|
|
486
476
|
try {
|
|
487
477
|
await this.#start(Math.min(30_000, 90_000 - (performance.now() - this.#episodeStart)));
|
|
488
|
-
if (this.#closing)
|
|
478
|
+
if (this.#closing || this.#recoveryStopped)
|
|
489
479
|
break;
|
|
490
480
|
this.#state = "ready";
|
|
491
481
|
this.#stableTimer = setTimeout(() => {
|
|
@@ -507,7 +497,7 @@ export class CodexService {
|
|
|
507
497
|
throw this.#failure ?? codexTransportError("CODEX_SERVICE_CLOSED");
|
|
508
498
|
})().finally(() => {
|
|
509
499
|
this.#supervision = undefined;
|
|
510
|
-
if (!this.#closing && this.#state === "recovering")
|
|
500
|
+
if (!this.#closing && !this.#recoveryStopped && this.#state === "recovering")
|
|
511
501
|
queueMicrotask(() => {
|
|
512
502
|
void this.#supervise(true).catch(() => { });
|
|
513
503
|
});
|
|
@@ -518,19 +508,19 @@ export class CodexService {
|
|
|
518
508
|
if (timeoutMs <= 0)
|
|
519
509
|
throw codexTransportError("CODEX_SERVICE_RECOVERY_EXHAUSTED");
|
|
520
510
|
const child = this.spawnFn(this.spec.command, this.spec.args, {
|
|
521
|
-
cwd: this.spec.cwd,
|
|
511
|
+
...(this.spec.cwd === undefined ? {} : { cwd: this.spec.cwd }),
|
|
522
512
|
env: this.spec.env
|
|
523
513
|
});
|
|
524
|
-
//
|
|
525
|
-
const removeGuard = watchLineLimit(child.stdout, () => [...this.#channels].
|
|
526
|
-
? Math.max(
|
|
527
|
-
:
|
|
514
|
+
// 连接解析预算取活动调用最大值;路由后各 client 再执行自己的更小预算。
|
|
515
|
+
const removeGuard = watchLineLimit(child.stdout, () => Math.max(this.#channels.size ? 0 : this.rawMessageMaxBytes, ...[...this.#channels].map((channel) => channel.allowInputEcho
|
|
516
|
+
? Math.max(channel.rawMessageMaxBytes, INVOKE_REQUEST_MAX_BYTES)
|
|
517
|
+
: channel.rawMessageMaxBytes)), (error) => this.#fault(current, error));
|
|
528
518
|
const current = {
|
|
529
519
|
number: ++this.#generation,
|
|
530
520
|
child,
|
|
521
|
+
// 保留原发送背压;控制条目不按少量并发预留,避免批量取消破坏共享连接。
|
|
531
522
|
writer: new CodexStdinWriter(child.stdin, (error) => this.#fault(current, error), {
|
|
532
|
-
|
|
533
|
-
maxBytes: 32 * 1024 * 1024
|
|
523
|
+
controlItems: DEFAULT_STREAM_LIMIT_POLICY.adapterQueueMaxItems
|
|
534
524
|
}),
|
|
535
525
|
reader: createInterface({ input: child.stdout }),
|
|
536
526
|
removeGuard,
|
|
@@ -583,6 +573,12 @@ export class CodexService {
|
|
|
583
573
|
throw error;
|
|
584
574
|
}
|
|
585
575
|
}
|
|
576
|
+
/** 宿主停止新获取/恢复,但已有健康 channel 仍可定向取消与收尾。 */
|
|
577
|
+
stopRecovery() {
|
|
578
|
+
this.#recoveryStopped = true;
|
|
579
|
+
this.#stop.abort();
|
|
580
|
+
clearTimeout(this.#stableTimer);
|
|
581
|
+
}
|
|
586
582
|
beginShutdown() {
|
|
587
583
|
if (this.#closing)
|
|
588
584
|
return;
|
|
@@ -622,8 +618,8 @@ export class CodexService {
|
|
|
622
618
|
const groups = new WeakSet();
|
|
623
619
|
const ownedChildren = new WeakSet();
|
|
624
620
|
function ownedSpawn(command, args, options) {
|
|
625
|
-
|
|
626
|
-
const child = spawn(
|
|
621
|
+
assertProviderCommand(command);
|
|
622
|
+
const child = spawn(command, [...args], {
|
|
627
623
|
...options,
|
|
628
624
|
stdio: "pipe",
|
|
629
625
|
detached: process.platform !== "win32",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-codex",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
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.13",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13"
|
|
10
10
|
},
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"files": [
|
|
@@ -28,7 +28,8 @@ export declare function createDshAdapter(options?: DshAdapterOptions): Readonly<
|
|
|
28
28
|
version?: undefined;
|
|
29
29
|
}>;
|
|
30
30
|
invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<CanonicalEvent>;
|
|
31
|
-
}, "metadata"> & {
|
|
31
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
32
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
32
33
|
metadata: Omit<{
|
|
33
34
|
type: string;
|
|
34
35
|
agentSources: "provisioned"[];
|
|
@@ -55,7 +56,8 @@ export declare const dshAdapter: Readonly<Omit<{
|
|
|
55
56
|
version?: undefined;
|
|
56
57
|
}>;
|
|
57
58
|
invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<CanonicalEvent>;
|
|
58
|
-
}, "metadata"> & {
|
|
59
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
60
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
59
61
|
metadata: Omit<{
|
|
60
62
|
type: string;
|
|
61
63
|
agentSources: "provisioned"[];
|
|
@@ -16,9 +16,10 @@ import {
|
|
|
16
16
|
} from "./chunk-H3S6WM37.js";
|
|
17
17
|
|
|
18
18
|
// packages/octo-runtime-adapter-dsh/dist/index.js
|
|
19
|
+
import { invocationOption, invocationProviderOptions, invocationModel, invocationApprovalMode, invocationRuntimeLimits, invocationWorkdir } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
19
20
|
import { randomUUID } from "node:crypto";
|
|
20
21
|
import { realpath } from "node:fs/promises";
|
|
21
|
-
import { defineAdapter, invocationEnvironment, providerInputParts,
|
|
22
|
+
import { defineAdapter, invocationEnvironment, providerInputParts, DriverQueue, noopRuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
22
23
|
import { contextActmode, DEFAULT_STREAM_LIMIT_POLICY, DEFAULT_RUN_TIMEOUT_MS } from "@mininglamp-oss/octo-runtime-protocol";
|
|
23
24
|
function failureEvent(error, diagnostics) {
|
|
24
25
|
return {
|
|
@@ -54,18 +55,18 @@ function createDshAdapter(options = {}) {
|
|
|
54
55
|
},
|
|
55
56
|
async *invoke(request, context) {
|
|
56
57
|
const invocationLog = context?.log ?? log;
|
|
57
|
-
if (request
|
|
58
|
+
if (invocationApprovalMode(request) !== "full_access")
|
|
58
59
|
throw new Error("APPROVAL_MODE_UNSUPPORTED: DSH SDK 0.2.1-rc.3 has no interactive approval transport; explicitly select full_access");
|
|
59
60
|
let config;
|
|
60
61
|
let sessionId;
|
|
61
62
|
let requestedId;
|
|
62
63
|
try {
|
|
63
|
-
const actmode = contextActmode(request.
|
|
64
|
+
const actmode = contextActmode(request.agentEnv);
|
|
64
65
|
if (actmode !== void 0 && actmode !== "default")
|
|
65
66
|
throw new DshError("DSH_ACTMODE_UNSUPPORTED");
|
|
66
|
-
if (request
|
|
67
|
+
if (invocationOption(request, "sandbox", "dsh") !== void 0 && invocationOption(request, "sandbox", "dsh") !== "danger-full-access")
|
|
67
68
|
throw new DshError("DSH_CONFIG_INVALID");
|
|
68
|
-
const configured = request
|
|
69
|
+
const configured = invocationProviderOptions(request, "dsh") ?? {};
|
|
69
70
|
if (!record(configured))
|
|
70
71
|
throw new DshError("DSH_CONFIG_INVALID");
|
|
71
72
|
config = configured;
|
|
@@ -144,7 +145,7 @@ function createDshAdapter(options = {}) {
|
|
|
144
145
|
} else {
|
|
145
146
|
const initializeTimeoutMs = timeoutOption(config, "initializeTimeoutMs", 15e3);
|
|
146
147
|
const requestTimeoutMs = timeoutOption(config, "requestTimeoutMs", 3e4);
|
|
147
|
-
const runTimeoutMs = request
|
|
148
|
+
const runTimeoutMs = invocationRuntimeLimits(request)?.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;
|
|
148
149
|
const shutdownTimeoutMs = timeoutOption(config, "shutdownTimeoutMs", 1e3);
|
|
149
150
|
const env = invocationEnvironment(request, {
|
|
150
151
|
DSH_PERMISSION_MODE: "danger-full-access"
|
|
@@ -157,7 +158,7 @@ function createDshAdapter(options = {}) {
|
|
|
157
158
|
client = new HarnessClient({
|
|
158
159
|
dshBin: launch.dshBin,
|
|
159
160
|
profile: stringOption(config, "profile", "sdk"),
|
|
160
|
-
processCwd: request
|
|
161
|
+
processCwd: invocationWorkdir(request),
|
|
161
162
|
env: launch.env,
|
|
162
163
|
initializeTimeoutMs,
|
|
163
164
|
requestTimeoutMs,
|
|
@@ -194,9 +195,9 @@ function createDshAdapter(options = {}) {
|
|
|
194
195
|
try {
|
|
195
196
|
phase = "initialize";
|
|
196
197
|
const initialization = await owned.initialize({
|
|
197
|
-
cwd: request
|
|
198
|
+
cwd: invocationWorkdir(request),
|
|
198
199
|
provider: stringOption(config, "provider", "deepseek-account"),
|
|
199
|
-
model: request
|
|
200
|
+
model: invocationModel(request) ?? "deepseek-flash",
|
|
200
201
|
...config.maxTokens === void 0 ? {} : { maxTokens: timeoutOption(config, "maxTokens", 4096) }
|
|
201
202
|
});
|
|
202
203
|
if (!record(initialization) || !record(initialization.serverInfo) || initialization.serverInfo.name !== "deepseek-harness-sdk-runtime" || typeof initialization.serverInfo.version !== "string" || !initialization.serverInfo.version.trim())
|
|
@@ -205,8 +206,8 @@ function createDshAdapter(options = {}) {
|
|
|
205
206
|
phase = "resume";
|
|
206
207
|
try {
|
|
207
208
|
await owned.resumeSession(sessionId);
|
|
208
|
-
const directory = await owned.setWorkingDirectory(sessionId, request
|
|
209
|
-
if (await realpath(directory) !== await realpath(request
|
|
209
|
+
const directory = await owned.setWorkingDirectory(sessionId, invocationWorkdir(request));
|
|
210
|
+
if (await realpath(directory) !== await realpath(invocationWorkdir(request)))
|
|
210
211
|
throw new DshError("DSH_SESSION_RESUME_FAILED");
|
|
211
212
|
} catch (error) {
|
|
212
213
|
throw new DshError("DSH_SESSION_RESUME_FAILED", dshError(error, "DSH_RPC_ERROR").diagnostics, { cause: error });
|
|
@@ -224,9 +225,6 @@ function createDshAdapter(options = {}) {
|
|
|
224
225
|
}
|
|
225
226
|
});
|
|
226
227
|
const contentBlocks = providerInputParts(request).map((part) => part.type === "image" ? { type: "image", mimeType: part.mimeType, data: part.data } : { type: "text", text: part.text });
|
|
227
|
-
const instructions = initialControlInstructions(request);
|
|
228
|
-
if (instructions)
|
|
229
|
-
contentBlocks.unshift({ type: "text", text: instructions });
|
|
230
228
|
phase = "prompt";
|
|
231
229
|
const receipt = await owned.prompt(sessionId, contentBlocks);
|
|
232
230
|
if (!receipt || receipt.length > 191)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-dsh",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
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.6",
|
|
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.13",
|
|
14
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.13"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AdapterMetadata } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
1
2
|
import { spawnGrokBuildAcpClient as spawnAcpClient, type SpawnGrokBuildClientOptions as SpawnAcpClientOptions } from "./client.js";
|
|
2
3
|
import { GrokBuildInteractionBridge as AcpApprovalBridge } from "./interactions.js";
|
|
3
4
|
import { acpActmodeSelectionRequest } from "@mininglamp-oss/octo-runtime-adapter-acp";
|
|
@@ -6,6 +7,7 @@ import { type ProbeResult, type ReasoningLevelMap, type AdapterInvocationContext
|
|
|
6
7
|
import { type InteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
|
|
7
8
|
type JsonRecord = Record<string, unknown>;
|
|
8
9
|
export interface AcpAdapterDefinition {
|
|
10
|
+
metadata?: AdapterMetadata;
|
|
9
11
|
type: string;
|
|
10
12
|
provider: string;
|
|
11
13
|
command: string;
|
|
@@ -20,7 +22,6 @@ export interface AcpAdapterDefinition {
|
|
|
20
22
|
isMissingSessionError?: (error: unknown) => boolean;
|
|
21
23
|
configureSession?: (client: AcpClient, session: JsonRecord, sessionId: string, request: InvokeRequest) => AsyncIterable<CanonicalEvent>;
|
|
22
24
|
selectActmode?: typeof acpActmodeSelectionRequest;
|
|
23
|
-
controlInstructions?: "session";
|
|
24
25
|
reasoningLevels?: ReasoningLevelMap;
|
|
25
26
|
clientOptions?: (request: InvokeRequest, bridge: AcpApprovalBridge) => Pick<SpawnAcpClientOptions, "requestHandler" | "onRequestResponseWritten" | "onRequestResponseFailed">;
|
|
26
27
|
validatePromptResult?: (update: StandardAcpUpdate) => CanonicalEvent[];
|
|
@@ -38,24 +39,23 @@ export interface StandardAcpUpdate extends AcpUpdate {
|
|
|
38
39
|
output?: unknown;
|
|
39
40
|
status?: string;
|
|
40
41
|
}
|
|
41
|
-
export declare function createGrokBuildAcpAdapter(definition: AcpAdapterDefinition, { acpClientFactory, command }?: {
|
|
42
|
+
export declare function createGrokBuildAcpAdapter(definition: AcpAdapterDefinition, { acpClientFactory, command, commandArgsPrefix, env }?: {
|
|
42
43
|
acpClientFactory?: typeof spawnAcpClient;
|
|
43
44
|
command?: string;
|
|
45
|
+
commandArgsPrefix?: readonly string[];
|
|
46
|
+
env?: NodeJS.ProcessEnv;
|
|
44
47
|
}): Readonly<Omit<{
|
|
45
|
-
metadata:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
metadata: AdapterMetadata;
|
|
49
|
+
probe: (() => Promise<ProbeResult>) | (() => Promise<{
|
|
50
|
+
available: false;
|
|
51
|
+
command: string;
|
|
52
|
+
reason: string;
|
|
53
|
+
}>);
|
|
51
54
|
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
52
55
|
invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<CanonicalEvent>;
|
|
53
|
-
}, "metadata"> & {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
type: string;
|
|
57
|
-
agentSources: "provisioned"[];
|
|
58
|
-
}, "protocolSupport"> & {
|
|
56
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
57
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
58
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
59
59
|
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
60
60
|
};
|
|
61
61
|
}>;
|