squad-openclaw 2026.2.2205 → 2026.2.2206
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/index.js +45 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2704,16 +2704,46 @@ function extractSessionKey(value) {
|
|
|
2704
2704
|
}
|
|
2705
2705
|
return null;
|
|
2706
2706
|
}
|
|
2707
|
+
function isInvoker(fn) {
|
|
2708
|
+
return typeof fn === "function";
|
|
2709
|
+
}
|
|
2710
|
+
async function callGatewayAny(ctx, api, method, params) {
|
|
2711
|
+
const ctxGateway = asRecord(ctx.gateway);
|
|
2712
|
+
const apiGateway = asRecord(api?.gateway);
|
|
2713
|
+
const candidates = [
|
|
2714
|
+
ctx.request,
|
|
2715
|
+
ctx.callGatewayMethod,
|
|
2716
|
+
ctx.gatewayRequest,
|
|
2717
|
+
ctx.invokeGatewayMethod,
|
|
2718
|
+
ctxGateway?.request,
|
|
2719
|
+
ctxGateway?.callGatewayMethod,
|
|
2720
|
+
api?.request,
|
|
2721
|
+
api?.callGatewayMethod,
|
|
2722
|
+
api?.gatewayRequest,
|
|
2723
|
+
api?.invokeGatewayMethod,
|
|
2724
|
+
apiGateway?.request,
|
|
2725
|
+
apiGateway?.callGatewayMethod
|
|
2726
|
+
];
|
|
2727
|
+
let lastErr = null;
|
|
2728
|
+
for (const candidate of candidates) {
|
|
2729
|
+
if (!isInvoker(candidate)) continue;
|
|
2730
|
+
try {
|
|
2731
|
+
return await candidate(method, params);
|
|
2732
|
+
} catch (err2) {
|
|
2733
|
+
lastErr = err2;
|
|
2734
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
2735
|
+
if (/unknown method|method .* unavailable|not found|invalid[_ ]request|does not exist/i.test(
|
|
2736
|
+
msg
|
|
2737
|
+
)) {
|
|
2738
|
+
continue;
|
|
2739
|
+
}
|
|
2740
|
+
throw err2;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
if (lastErr) throw lastErr;
|
|
2744
|
+
throw new Error("Gateway method invocation API unavailable in plugin context");
|
|
2745
|
+
}
|
|
2707
2746
|
function registerSessionMethods(api) {
|
|
2708
|
-
const callGateway = async (ctx, method, params = {}) => {
|
|
2709
|
-
const ctxRequest = ctx.request;
|
|
2710
|
-
if (typeof ctxRequest === "function") return ctxRequest(method, params);
|
|
2711
|
-
const apiRequest = api?.request;
|
|
2712
|
-
if (typeof apiRequest === "function") return apiRequest(method, params);
|
|
2713
|
-
const apiCallGatewayMethod = api?.callGatewayMethod;
|
|
2714
|
-
if (typeof apiCallGatewayMethod === "function") return apiCallGatewayMethod(method, params);
|
|
2715
|
-
throw new Error("Gateway method invocation API unavailable in plugin context");
|
|
2716
|
-
};
|
|
2717
2747
|
api.registerGatewayMethod(
|
|
2718
2748
|
"squad.sessions.create",
|
|
2719
2749
|
async (ctx) => {
|
|
@@ -2737,7 +2767,12 @@ function registerSessionMethods(api) {
|
|
|
2737
2767
|
...typeof agentId === "string" ? { agentId: agentId.trim() } : {}
|
|
2738
2768
|
};
|
|
2739
2769
|
try {
|
|
2740
|
-
const nativeResult = await
|
|
2770
|
+
const nativeResult = await callGatewayAny(
|
|
2771
|
+
ctx,
|
|
2772
|
+
api,
|
|
2773
|
+
"sessions.create",
|
|
2774
|
+
createParams
|
|
2775
|
+
);
|
|
2741
2776
|
const normalizedKey = extractSessionKey(nativeResult) ?? (typeof sessionKey === "string" ? sessionKey.trim() : null);
|
|
2742
2777
|
if (!normalizedKey) {
|
|
2743
2778
|
respond(false, {
|
package/package.json
CHANGED