@openclaw/acpx 2026.7.2-beta.7 → 2026.8.1-beta.3
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/dist/{config-schema-lrk5nlcV.js → config-schema-DN_uAi4R.js} +0 -2
- package/dist/doctor-contract-api.js +36 -4
- package/dist/index.js +47 -1318
- package/dist/pi-session-catalog-runtime-BIu-8uRZ.js +887 -0
- package/dist/pi-session-paths-EMbd4Hkz.js +84 -0
- package/dist/{process-lease-DSLDgiNl.js → process-lease-Cwvj7WGe.js} +5 -2
- package/dist/{process-reaper-DFwbcdPa.js → process-reaper-DduWm_7N.js} +66 -24
- package/dist/register.runtime-Dj29TKFy.js +180 -0
- package/dist/register.runtime.js +1 -1
- package/dist/{runtime-By_lR8uk.js → runtime-BmOxa15I.js} +89 -67
- package/dist/{service-CBZSAymH.js → service-PRlUtXMf.js} +39 -45
- package/openclaw.plugin.json +5 -17
- package/package.json +5 -5
- package/dist/register.runtime-BbS2JTTv.js +0 -263
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { getAcpRuntimeBackend, registerAcpRuntimeBackend, unregisterAcpRuntimeBackend } from "openclaw/plugin-sdk/acp-runtime-backend";
|
|
2
|
-
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
3
|
-
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
4
|
-
//#region extensions/acpx/src/runtime-turn.ts
|
|
5
|
-
/**
|
|
6
|
-
* ACPX turn adapters. Modern runtimes can expose startTurn directly; legacy
|
|
7
|
-
* runtimes that only stream runTurn events are adapted to the newer contract.
|
|
8
|
-
*/
|
|
9
|
-
function isCancellationStopReason(stopReason) {
|
|
10
|
-
return stopReason === "cancel" || stopReason === "cancelled" || stopReason === "manual-cancel";
|
|
11
|
-
}
|
|
12
|
-
var LegacyRunTurnEventQueue = class {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.items = [];
|
|
15
|
-
this.waits = [];
|
|
16
|
-
this.closed = false;
|
|
17
|
-
}
|
|
18
|
-
push(item) {
|
|
19
|
-
if (this.closed) return;
|
|
20
|
-
const waiter = this.waits.shift();
|
|
21
|
-
if (waiter) {
|
|
22
|
-
waiter.resolve(item);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
this.items.push(item);
|
|
26
|
-
}
|
|
27
|
-
clear() {
|
|
28
|
-
this.items.length = 0;
|
|
29
|
-
}
|
|
30
|
-
close() {
|
|
31
|
-
if (this.closed) return;
|
|
32
|
-
this.closed = true;
|
|
33
|
-
for (const waiter of this.waits.splice(0)) waiter.resolve(null);
|
|
34
|
-
}
|
|
35
|
-
fail(error) {
|
|
36
|
-
if (this.closed) return;
|
|
37
|
-
this.error = error;
|
|
38
|
-
this.closed = true;
|
|
39
|
-
for (const waiter of this.waits.splice(0)) waiter.reject(error);
|
|
40
|
-
}
|
|
41
|
-
async next() {
|
|
42
|
-
const item = this.items.shift();
|
|
43
|
-
if (item) return item;
|
|
44
|
-
if (this.error) throw toLintErrorObject(this.error, "Non-Error thrown");
|
|
45
|
-
if (this.closed) return null;
|
|
46
|
-
return await new Promise((resolve, reject) => {
|
|
47
|
-
this.waits.push({
|
|
48
|
-
resolve,
|
|
49
|
-
reject
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
async *iterate() {
|
|
54
|
-
for (;;) {
|
|
55
|
-
const item = await this.next();
|
|
56
|
-
if (!item) return;
|
|
57
|
-
yield item;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
function legacyRunTurnAsStartTurn(runtime, input) {
|
|
62
|
-
const result = createDeferred();
|
|
63
|
-
result.promise.catch(() => {});
|
|
64
|
-
const queue = new LegacyRunTurnEventQueue();
|
|
65
|
-
let resultSettled = false;
|
|
66
|
-
const settleResult = (next) => {
|
|
67
|
-
if (resultSettled) return;
|
|
68
|
-
resultSettled = true;
|
|
69
|
-
result.resolve(next);
|
|
70
|
-
};
|
|
71
|
-
(async () => {
|
|
72
|
-
try {
|
|
73
|
-
for await (const event of runtime.runTurn(input)) {
|
|
74
|
-
if (event.type === "done") {
|
|
75
|
-
settleResult({
|
|
76
|
-
status: event.status ?? (isCancellationStopReason(event.stopReason) ? "cancelled" : "completed"),
|
|
77
|
-
...event.stopReason ? { stopReason: event.stopReason } : {}
|
|
78
|
-
});
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if (event.type === "error") {
|
|
82
|
-
settleResult({
|
|
83
|
-
status: "failed",
|
|
84
|
-
error: {
|
|
85
|
-
message: event.message,
|
|
86
|
-
...event.code ? { code: event.code } : {},
|
|
87
|
-
...event.detailCode ? { detailCode: event.detailCode } : {},
|
|
88
|
-
...event.retryable === void 0 ? {} : { retryable: event.retryable }
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
queue.push(event);
|
|
94
|
-
}
|
|
95
|
-
settleResult({
|
|
96
|
-
status: "failed",
|
|
97
|
-
error: {
|
|
98
|
-
code: "ACP_TURN_FAILED",
|
|
99
|
-
message: "ACP turn ended without a terminal done event."
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
} catch (error) {
|
|
103
|
-
result.reject(error);
|
|
104
|
-
queue.fail(error);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
queue.close();
|
|
108
|
-
})();
|
|
109
|
-
return {
|
|
110
|
-
requestId: input.requestId,
|
|
111
|
-
events: queue.iterate(),
|
|
112
|
-
result: result.promise,
|
|
113
|
-
async cancel(inputArgs) {
|
|
114
|
-
await runtime.cancel({
|
|
115
|
-
handle: input.handle,
|
|
116
|
-
reason: inputArgs?.reason
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
async closeStream() {
|
|
120
|
-
queue.clear();
|
|
121
|
-
queue.close();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/** Start an ACP turn, adapting legacy runTurn-only runtimes when needed. */
|
|
126
|
-
function startRuntimeTurn(runtime, input) {
|
|
127
|
-
return runtime.startTurn?.(input) ?? legacyRunTurnAsStartTurn(runtime, input);
|
|
128
|
-
}
|
|
129
|
-
/** Start an ACP turn through a lazy runtime resolver. */
|
|
130
|
-
function lazyStartRuntimeTurn(resolveRuntime, input) {
|
|
131
|
-
const turnPromise = resolveRuntime().then((runtime) => startRuntimeTurn(runtime, input));
|
|
132
|
-
return {
|
|
133
|
-
requestId: input.requestId,
|
|
134
|
-
events: { async *[Symbol.asyncIterator]() {
|
|
135
|
-
yield* (await turnPromise).events;
|
|
136
|
-
} },
|
|
137
|
-
result: turnPromise.then((turn) => turn.result),
|
|
138
|
-
cancel(inputArgs) {
|
|
139
|
-
return turnPromise.then((turn) => turn.cancel(inputArgs));
|
|
140
|
-
},
|
|
141
|
-
closeStream(inputArgs) {
|
|
142
|
-
return turnPromise.then((turn) => turn.closeStream(inputArgs));
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function toLintErrorObject(value, fallbackMessage) {
|
|
147
|
-
if (value instanceof Error) return value;
|
|
148
|
-
if (typeof value === "string") return new Error(value);
|
|
149
|
-
const error = new Error(fallbackMessage, { cause: value });
|
|
150
|
-
if (typeof value === "object" && value !== null || typeof value === "function") Object.assign(error, value);
|
|
151
|
-
return error;
|
|
152
|
-
}
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region extensions/acpx/src/runtime-proxy.ts
|
|
155
|
-
/** Create an ACP runtime facade backed by an async runtime resolver. */
|
|
156
|
-
function createLazyAcpRuntimeProxy(resolveRuntime) {
|
|
157
|
-
return {
|
|
158
|
-
async ensureSession(input) {
|
|
159
|
-
return await (await resolveRuntime()).ensureSession(input);
|
|
160
|
-
},
|
|
161
|
-
startTurn(input) {
|
|
162
|
-
return lazyStartRuntimeTurn(resolveRuntime, input);
|
|
163
|
-
},
|
|
164
|
-
async *runTurn(input) {
|
|
165
|
-
yield* (await resolveRuntime()).runTurn(input);
|
|
166
|
-
},
|
|
167
|
-
async getCapabilities(input) {
|
|
168
|
-
return await (await resolveRuntime()).getCapabilities?.(input) ?? { controls: [] };
|
|
169
|
-
},
|
|
170
|
-
async getStatus(input) {
|
|
171
|
-
return await (await resolveRuntime()).getStatus?.(input) ?? {};
|
|
172
|
-
},
|
|
173
|
-
async setMode(input) {
|
|
174
|
-
await (await resolveRuntime()).setMode?.(input);
|
|
175
|
-
},
|
|
176
|
-
async setConfigOption(input) {
|
|
177
|
-
await (await resolveRuntime()).setConfigOption?.(input);
|
|
178
|
-
},
|
|
179
|
-
async doctor() {
|
|
180
|
-
return await (await resolveRuntime()).doctor?.() ?? {
|
|
181
|
-
ok: true,
|
|
182
|
-
message: "ok"
|
|
183
|
-
};
|
|
184
|
-
},
|
|
185
|
-
async prepareFreshSession(input) {
|
|
186
|
-
await (await resolveRuntime()).prepareFreshSession?.(input);
|
|
187
|
-
},
|
|
188
|
-
async cancel(input) {
|
|
189
|
-
await (await resolveRuntime()).cancel(input);
|
|
190
|
-
},
|
|
191
|
-
async close(input) {
|
|
192
|
-
await (await resolveRuntime()).close(input);
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
//#endregion
|
|
197
|
-
//#region extensions/acpx/register.runtime.ts
|
|
198
|
-
/**
|
|
199
|
-
* Lazy ACPX runtime service registration. The plugin exposes an ACP backend
|
|
200
|
-
* immediately, then imports the heavier service only when a session needs it.
|
|
201
|
-
*/
|
|
202
|
-
const ACPX_BACKEND_ID = "acpx";
|
|
203
|
-
const loadServiceModule = createLazyRuntimeModule(() => import("./service-CBZSAymH.js"));
|
|
204
|
-
async function startRealService(state) {
|
|
205
|
-
if (state.realRuntime) return state.realRuntime;
|
|
206
|
-
if (!state.ctx) throw new Error("ACPX runtime service is not started");
|
|
207
|
-
state.startPromise ??= (async () => {
|
|
208
|
-
const { createAcpxRuntimeService: createAcpxRuntimeServiceLocal } = await loadServiceModule();
|
|
209
|
-
const service = createAcpxRuntimeServiceLocal(state.params);
|
|
210
|
-
state.realService = service;
|
|
211
|
-
await service.start(state.ctx);
|
|
212
|
-
const backend = getAcpRuntimeBackend(ACPX_BACKEND_ID);
|
|
213
|
-
if (!backend?.runtime) throw new Error("ACPX runtime service did not register an ACP backend");
|
|
214
|
-
state.realRuntime = backend.runtime;
|
|
215
|
-
return state.realRuntime;
|
|
216
|
-
})();
|
|
217
|
-
try {
|
|
218
|
-
return await state.startPromise;
|
|
219
|
-
} catch (error) {
|
|
220
|
-
state.startPromise = null;
|
|
221
|
-
state.realService = null;
|
|
222
|
-
throw error;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
function createDeferredRuntime(state) {
|
|
226
|
-
const resolveRuntime = () => startRealService(state);
|
|
227
|
-
return createLazyAcpRuntimeProxy(resolveRuntime);
|
|
228
|
-
}
|
|
229
|
-
/** Creates the plugin service that registers ACPX as an ACP runtime backend. */
|
|
230
|
-
function createAcpxRuntimeService(params = {}) {
|
|
231
|
-
const state = {
|
|
232
|
-
ctx: null,
|
|
233
|
-
params,
|
|
234
|
-
realRuntime: null,
|
|
235
|
-
realService: null,
|
|
236
|
-
startPromise: null
|
|
237
|
-
};
|
|
238
|
-
return {
|
|
239
|
-
id: "acpx-runtime",
|
|
240
|
-
async start(ctx) {
|
|
241
|
-
if (process.env.OPENCLAW_SKIP_ACPX_RUNTIME === "1") {
|
|
242
|
-
ctx.logger.info("skipping embedded acpx runtime backend (OPENCLAW_SKIP_ACPX_RUNTIME=1)");
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
state.ctx = ctx;
|
|
246
|
-
registerAcpRuntimeBackend({
|
|
247
|
-
id: ACPX_BACKEND_ID,
|
|
248
|
-
runtime: createDeferredRuntime(state)
|
|
249
|
-
});
|
|
250
|
-
ctx.logger.info("embedded acpx runtime backend registered lazily");
|
|
251
|
-
},
|
|
252
|
-
async stop(ctx) {
|
|
253
|
-
if (state.realService) await state.realService.stop?.(ctx);
|
|
254
|
-
else unregisterAcpRuntimeBackend(ACPX_BACKEND_ID);
|
|
255
|
-
state.ctx = null;
|
|
256
|
-
state.realRuntime = null;
|
|
257
|
-
state.realService = null;
|
|
258
|
-
state.startPromise = null;
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
//#endregion
|
|
263
|
-
export { createLazyAcpRuntimeProxy as n, createAcpxRuntimeService as t };
|