@remnic/plugin-openclaw 9.54.5 → 9.54.7
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 +5 -1
- package/dist/chunk-HDTN2ZKK.js +40 -0
- package/dist/index.js +385 -32
- package/dist/support-passport-model-route.d.ts +7 -0
- package/dist/support-passport-model-route.js +7 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +9 -3
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createOpenClawSupportPassportModelRoute
|
|
3
|
+
} from "./chunk-HDTN2ZKK.js";
|
|
1
4
|
import {
|
|
2
5
|
__export,
|
|
3
6
|
__reExport
|
|
@@ -3103,8 +3106,8 @@ import { registerLcmTools } from "@remnic/core/lcm/index";
|
|
|
3103
3106
|
import { estimateTokens as estimateLcmTokens } from "@remnic/core/lcm/archive";
|
|
3104
3107
|
import { registerCli } from "@remnic/core/cli";
|
|
3105
3108
|
import {
|
|
3106
|
-
FallbackLlmClient,
|
|
3107
|
-
fallbackLlmRuntimeContextFromConfig
|
|
3109
|
+
FallbackLlmClient as FallbackLlmClient2,
|
|
3110
|
+
fallbackLlmRuntimeContextFromConfig as fallbackLlmRuntimeContextFromConfig2
|
|
3108
3111
|
} from "@remnic/core/fallback-llm";
|
|
3109
3112
|
|
|
3110
3113
|
// ../../src/objective-state.ts
|
|
@@ -3133,8 +3136,36 @@ async function probeQmdAvailability(host) {
|
|
|
3133
3136
|
|
|
3134
3137
|
// ../../src/access-service.ts
|
|
3135
3138
|
var access_service_exports = {};
|
|
3139
|
+
__export(access_service_exports, {
|
|
3140
|
+
EngramAccessService: () => EngramAccessService,
|
|
3141
|
+
createConfiguredSupportPassportGatewayRoute: () => createConfiguredSupportPassportGatewayRoute
|
|
3142
|
+
});
|
|
3136
3143
|
__reExport(access_service_exports, access_service_star);
|
|
3137
3144
|
import * as access_service_star from "@remnic/core/access-service";
|
|
3145
|
+
import { EngramAccessService as CoreEngramAccessService } from "@remnic/core/access-service";
|
|
3146
|
+
import { FallbackLlmClient, fallbackLlmRuntimeContextFromConfig } from "@remnic/core/fallback-llm";
|
|
3147
|
+
import { createOpenClawSupportPassportModelRoute as createOpenClawSupportPassportModelRoute2 } from "@remnic/plugin-openclaw/support-passport-model-route";
|
|
3148
|
+
function createConfiguredSupportPassportGatewayRoute(config, preferredClient) {
|
|
3149
|
+
const gatewayClient = preferredClient ?? (config.gatewayConfig ? new FallbackLlmClient(
|
|
3150
|
+
config.gatewayConfig,
|
|
3151
|
+
fallbackLlmRuntimeContextFromConfig(config)
|
|
3152
|
+
) : null);
|
|
3153
|
+
return gatewayClient ? createOpenClawSupportPassportModelRoute2(config, gatewayClient) : null;
|
|
3154
|
+
}
|
|
3155
|
+
var EngramAccessService = class extends CoreEngramAccessService {
|
|
3156
|
+
supportPassportGatewayRoute;
|
|
3157
|
+
constructor(orchestrator, options = {}) {
|
|
3158
|
+
super(orchestrator, options);
|
|
3159
|
+
const injectedRoute = super.supportPassportGatewayRouteRef;
|
|
3160
|
+
this.supportPassportGatewayRoute = injectedRoute ?? createConfiguredSupportPassportGatewayRoute(
|
|
3161
|
+
orchestrator.config,
|
|
3162
|
+
orchestrator.fastGatewayLlm
|
|
3163
|
+
);
|
|
3164
|
+
}
|
|
3165
|
+
get supportPassportGatewayRouteRef() {
|
|
3166
|
+
return this.supportPassportGatewayRoute;
|
|
3167
|
+
}
|
|
3168
|
+
};
|
|
3138
3169
|
|
|
3139
3170
|
// ../../src/access-http.ts
|
|
3140
3171
|
var access_http_exports = {};
|
|
@@ -5364,7 +5395,7 @@ import path8 from "path";
|
|
|
5364
5395
|
import {
|
|
5365
5396
|
renderMemoryContextPrompt
|
|
5366
5397
|
} from "@remnic/core";
|
|
5367
|
-
import { log as
|
|
5398
|
+
import { log as log7 } from "@remnic/core/logger";
|
|
5368
5399
|
|
|
5369
5400
|
// src/delegate-authorization.ts
|
|
5370
5401
|
import { log as log2 } from "@remnic/core/logger";
|
|
@@ -7680,8 +7711,301 @@ function registerDelegateMemoryCapability(api, options) {
|
|
|
7680
7711
|
return built;
|
|
7681
7712
|
}
|
|
7682
7713
|
|
|
7714
|
+
// src/delegate-support-passport-model.ts
|
|
7715
|
+
import {
|
|
7716
|
+
SUPPORT_PASSPORT_MODEL_ACK_PATH,
|
|
7717
|
+
SUPPORT_PASSPORT_MODEL_JOB_PATH,
|
|
7718
|
+
SUPPORT_PASSPORT_MODEL_RESULT_PATH,
|
|
7719
|
+
acceptsSupportPassportModelResponse,
|
|
7720
|
+
parseSupportPassportModelJob
|
|
7721
|
+
} from "@remnic/core";
|
|
7722
|
+
import { log as log6 } from "@remnic/core/logger";
|
|
7723
|
+
var MODEL_WORKER_COUNT = 4;
|
|
7724
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 25e3;
|
|
7725
|
+
var RESULT_REQUEST_TIMEOUT_MS = 5e3;
|
|
7726
|
+
var RESULT_RETRY_DELAY_MS = 1e3;
|
|
7727
|
+
var POLL_RETRY_MAX_DELAY_MS = 3e4;
|
|
7728
|
+
var SHUTDOWN_RESULT_REQUEST_TIMEOUT_MS = 250;
|
|
7729
|
+
function supportPassportModelPollRetryDelayMs(consecutiveFailures) {
|
|
7730
|
+
const exponent = Math.max(0, Math.min(30, Math.floor(consecutiveFailures) - 1));
|
|
7731
|
+
return Math.min(POLL_RETRY_MAX_DELAY_MS, RESULT_RETRY_DELAY_MS * 2 ** exponent);
|
|
7732
|
+
}
|
|
7733
|
+
async function post(target, serviceId, pathname, body, signal, timeoutMs) {
|
|
7734
|
+
const auth = target.resolveAuthToken();
|
|
7735
|
+
const requestSignal = AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]);
|
|
7736
|
+
const response = await fetch(daemonUrl(target, pathname), {
|
|
7737
|
+
method: "POST",
|
|
7738
|
+
headers: {
|
|
7739
|
+
"content-type": "application/json",
|
|
7740
|
+
...auth.token ? { Authorization: `Bearer ${auth.token}` } : {}
|
|
7741
|
+
},
|
|
7742
|
+
body: JSON.stringify(body),
|
|
7743
|
+
signal: requestSignal
|
|
7744
|
+
});
|
|
7745
|
+
if (response.status === 401 || response.status === 403) {
|
|
7746
|
+
reportDaemonAuthorizationFailure(serviceId, pathname, response.status, auth.source);
|
|
7747
|
+
}
|
|
7748
|
+
return response;
|
|
7749
|
+
}
|
|
7750
|
+
function abortableRetryDelay(signal, delayMs = RESULT_RETRY_DELAY_MS) {
|
|
7751
|
+
if (signal.aborted) return Promise.resolve();
|
|
7752
|
+
return new Promise((resolve) => {
|
|
7753
|
+
const done = () => {
|
|
7754
|
+
clearTimeout(timeout);
|
|
7755
|
+
signal.removeEventListener("abort", done);
|
|
7756
|
+
resolve();
|
|
7757
|
+
};
|
|
7758
|
+
const timeout = setTimeout(done, delayMs);
|
|
7759
|
+
signal.addEventListener("abort", done, { once: true });
|
|
7760
|
+
});
|
|
7761
|
+
}
|
|
7762
|
+
function createDelegateSupportPassportModelService(options) {
|
|
7763
|
+
let controller;
|
|
7764
|
+
let worker;
|
|
7765
|
+
const requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
7766
|
+
if (!Number.isInteger(requestTimeoutMs) || requestTimeoutMs < 1) {
|
|
7767
|
+
throw new Error("requestTimeoutMs must be a positive integer");
|
|
7768
|
+
}
|
|
7769
|
+
const invoke = async (job, signal) => {
|
|
7770
|
+
const timeoutSignal = AbortSignal.timeout(job.timeoutMs);
|
|
7771
|
+
const modelSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
7772
|
+
if (modelSignal.aborted) return null;
|
|
7773
|
+
let removeAbort = () => {
|
|
7774
|
+
};
|
|
7775
|
+
const aborted = new Promise((resolve) => {
|
|
7776
|
+
const onAbort = () => resolve(null);
|
|
7777
|
+
modelSignal.addEventListener("abort", onAbort, { once: true });
|
|
7778
|
+
removeAbort = () => modelSignal.removeEventListener("abort", onAbort);
|
|
7779
|
+
});
|
|
7780
|
+
try {
|
|
7781
|
+
return await Promise.race([
|
|
7782
|
+
options.route.invoke(job.messages, {
|
|
7783
|
+
temperature: job.temperature,
|
|
7784
|
+
maxTokens: job.maxTokens,
|
|
7785
|
+
timeoutMs: job.timeoutMs,
|
|
7786
|
+
signal: modelSignal,
|
|
7787
|
+
operation: job.operation,
|
|
7788
|
+
jsonSchema: job.jsonSchema,
|
|
7789
|
+
acceptResponse: (candidate) => acceptsSupportPassportModelResponse(job.operation, job.messages, candidate.content)
|
|
7790
|
+
}),
|
|
7791
|
+
aborted
|
|
7792
|
+
]);
|
|
7793
|
+
} catch (error) {
|
|
7794
|
+
if (!modelSignal.aborted) {
|
|
7795
|
+
log6.warn(`delegate support passport model call failed: ${String(error)}`);
|
|
7796
|
+
}
|
|
7797
|
+
return null;
|
|
7798
|
+
} finally {
|
|
7799
|
+
removeAbort();
|
|
7800
|
+
}
|
|
7801
|
+
};
|
|
7802
|
+
const completeDuringShutdown = async (job, deadline) => {
|
|
7803
|
+
const remainingMs = deadline - Date.now();
|
|
7804
|
+
if (remainingMs <= 0) return;
|
|
7805
|
+
const shutdownTimeoutMs = Math.min(SHUTDOWN_RESULT_REQUEST_TIMEOUT_MS, remainingMs);
|
|
7806
|
+
const completion = await post(
|
|
7807
|
+
options.target,
|
|
7808
|
+
options.serviceId,
|
|
7809
|
+
SUPPORT_PASSPORT_MODEL_RESULT_PATH,
|
|
7810
|
+
{ id: job.id, claimId: job.claimId, result: null },
|
|
7811
|
+
AbortSignal.timeout(shutdownTimeoutMs),
|
|
7812
|
+
shutdownTimeoutMs
|
|
7813
|
+
);
|
|
7814
|
+
await completion.body?.cancel();
|
|
7815
|
+
if (!completion.ok && completion.status !== 404) {
|
|
7816
|
+
throw new Error(`delegate support passport model completion was rejected with HTTP ${completion.status}`);
|
|
7817
|
+
}
|
|
7818
|
+
};
|
|
7819
|
+
const complete = async (job, result, signal, deadline, serviceSignal, onAccepted) => {
|
|
7820
|
+
if (signal.aborted) {
|
|
7821
|
+
if (serviceSignal.aborted) await completeDuringShutdown(job, deadline);
|
|
7822
|
+
return;
|
|
7823
|
+
}
|
|
7824
|
+
let lastFailure = "the job deadline elapsed";
|
|
7825
|
+
while (!signal.aborted && Date.now() < deadline) {
|
|
7826
|
+
const remainingMs = deadline - Date.now();
|
|
7827
|
+
let completion;
|
|
7828
|
+
try {
|
|
7829
|
+
completion = await post(
|
|
7830
|
+
options.target,
|
|
7831
|
+
options.serviceId,
|
|
7832
|
+
SUPPORT_PASSPORT_MODEL_RESULT_PATH,
|
|
7833
|
+
{ id: job.id, claimId: job.claimId, result },
|
|
7834
|
+
signal,
|
|
7835
|
+
Math.min(RESULT_REQUEST_TIMEOUT_MS, remainingMs)
|
|
7836
|
+
);
|
|
7837
|
+
} catch (error) {
|
|
7838
|
+
if (signal.aborted) {
|
|
7839
|
+
if (serviceSignal.aborted) await completeDuringShutdown(job, deadline);
|
|
7840
|
+
return;
|
|
7841
|
+
}
|
|
7842
|
+
lastFailure = String(error);
|
|
7843
|
+
const retryDelayMs2 = Math.min(RESULT_RETRY_DELAY_MS, deadline - Date.now());
|
|
7844
|
+
if (retryDelayMs2 > 0) await abortableRetryDelay(signal, retryDelayMs2);
|
|
7845
|
+
continue;
|
|
7846
|
+
}
|
|
7847
|
+
const status = completion.status;
|
|
7848
|
+
if (completion.ok) {
|
|
7849
|
+
onAccepted();
|
|
7850
|
+
await completion.body?.cancel().catch(() => void 0);
|
|
7851
|
+
return;
|
|
7852
|
+
}
|
|
7853
|
+
await completion.body?.cancel();
|
|
7854
|
+
if (status !== 408 && status !== 425 && status !== 429 && status < 500) {
|
|
7855
|
+
throw new Error(`delegate support passport model completion was rejected with HTTP ${status}`);
|
|
7856
|
+
}
|
|
7857
|
+
if (signal.aborted) {
|
|
7858
|
+
if (serviceSignal.aborted) await completeDuringShutdown(job, deadline);
|
|
7859
|
+
return;
|
|
7860
|
+
}
|
|
7861
|
+
lastFailure = `HTTP ${status}`;
|
|
7862
|
+
const retryDelayMs = Math.min(RESULT_RETRY_DELAY_MS, deadline - Date.now());
|
|
7863
|
+
if (retryDelayMs > 0) await abortableRetryDelay(signal, retryDelayMs);
|
|
7864
|
+
}
|
|
7865
|
+
if (signal.aborted) {
|
|
7866
|
+
if (serviceSignal.aborted) await completeDuringShutdown(job, deadline);
|
|
7867
|
+
return;
|
|
7868
|
+
}
|
|
7869
|
+
throw new Error(`delegate support passport model completion missed its deadline after ${lastFailure}`);
|
|
7870
|
+
};
|
|
7871
|
+
const acknowledge = async (job, signal, timeoutMs, settleOnShutdown = false) => {
|
|
7872
|
+
if (!job.claimId) return true;
|
|
7873
|
+
const deadline = Date.now() + Math.min(job.timeoutMs, timeoutMs);
|
|
7874
|
+
while (!signal.aborted && Date.now() < deadline) {
|
|
7875
|
+
const remainingMs = deadline - Date.now();
|
|
7876
|
+
try {
|
|
7877
|
+
const response = await post(
|
|
7878
|
+
options.target,
|
|
7879
|
+
options.serviceId,
|
|
7880
|
+
SUPPORT_PASSPORT_MODEL_ACK_PATH,
|
|
7881
|
+
{ id: job.id, claimId: job.claimId },
|
|
7882
|
+
signal,
|
|
7883
|
+
Math.min(RESULT_REQUEST_TIMEOUT_MS, remainingMs)
|
|
7884
|
+
);
|
|
7885
|
+
const status = response.status;
|
|
7886
|
+
await response.body?.cancel();
|
|
7887
|
+
if (response.ok) return true;
|
|
7888
|
+
if (status !== 408 && status !== 425 && status !== 429 && status < 500) return false;
|
|
7889
|
+
} catch {
|
|
7890
|
+
if (signal.aborted) {
|
|
7891
|
+
if (settleOnShutdown) await completeDuringShutdown(job, deadline);
|
|
7892
|
+
return false;
|
|
7893
|
+
}
|
|
7894
|
+
}
|
|
7895
|
+
const retryDelayMs = Math.min(RESULT_RETRY_DELAY_MS, deadline - Date.now());
|
|
7896
|
+
if (retryDelayMs > 0) await abortableRetryDelay(signal, retryDelayMs);
|
|
7897
|
+
}
|
|
7898
|
+
if (signal.aborted && settleOnShutdown) await completeDuringShutdown(job, deadline);
|
|
7899
|
+
return false;
|
|
7900
|
+
};
|
|
7901
|
+
const maintainClaim = async (job, signal, deadline) => {
|
|
7902
|
+
if (!job.claimId || !job.executionLeaseTimeoutMs) return;
|
|
7903
|
+
const renewalDelayMs = Math.max(1, Math.floor(job.executionLeaseTimeoutMs / 3));
|
|
7904
|
+
const renewalTimeoutMs = Math.max(1, job.executionLeaseTimeoutMs - renewalDelayMs);
|
|
7905
|
+
while (!signal.aborted && Date.now() < deadline) {
|
|
7906
|
+
await abortableRetryDelay(signal, Math.min(renewalDelayMs, deadline - Date.now()));
|
|
7907
|
+
if (signal.aborted || Date.now() >= deadline) return;
|
|
7908
|
+
if (!await acknowledge(job, signal, Math.min(renewalTimeoutMs, deadline - Date.now()))) {
|
|
7909
|
+
throw new Error("delegate support passport model claim lease renewal failed");
|
|
7910
|
+
}
|
|
7911
|
+
}
|
|
7912
|
+
};
|
|
7913
|
+
const runPoller = async (signal) => {
|
|
7914
|
+
let consecutiveFailures = 0;
|
|
7915
|
+
const delayAfterFailure = async () => {
|
|
7916
|
+
consecutiveFailures += 1;
|
|
7917
|
+
await abortableRetryDelay(signal, supportPassportModelPollRetryDelayMs(consecutiveFailures));
|
|
7918
|
+
};
|
|
7919
|
+
while (!signal.aborted) {
|
|
7920
|
+
try {
|
|
7921
|
+
const response = await post(
|
|
7922
|
+
options.target,
|
|
7923
|
+
options.serviceId,
|
|
7924
|
+
SUPPORT_PASSPORT_MODEL_JOB_PATH,
|
|
7925
|
+
{ timeoutMs: 2e4, claimLease: true },
|
|
7926
|
+
signal,
|
|
7927
|
+
requestTimeoutMs
|
|
7928
|
+
);
|
|
7929
|
+
if (response.status === 204) {
|
|
7930
|
+
consecutiveFailures = 0;
|
|
7931
|
+
continue;
|
|
7932
|
+
}
|
|
7933
|
+
if (!response.ok) {
|
|
7934
|
+
await response.body?.cancel();
|
|
7935
|
+
await delayAfterFailure();
|
|
7936
|
+
continue;
|
|
7937
|
+
}
|
|
7938
|
+
const job = parseSupportPassportModelJob(await response.json());
|
|
7939
|
+
if (!job) {
|
|
7940
|
+
log6.warn("delegate support passport model bridge received an invalid job");
|
|
7941
|
+
await delayAfterFailure();
|
|
7942
|
+
continue;
|
|
7943
|
+
}
|
|
7944
|
+
consecutiveFailures = 0;
|
|
7945
|
+
const deadline = Date.now() + job.timeoutMs;
|
|
7946
|
+
if (!await acknowledge(job, signal, job.claimAckTimeoutMs ?? job.timeoutMs, true)) {
|
|
7947
|
+
log6.warn("delegate support passport model bridge could not acknowledge a claimed job");
|
|
7948
|
+
await delayAfterFailure();
|
|
7949
|
+
continue;
|
|
7950
|
+
}
|
|
7951
|
+
const remainingMs = deadline - Date.now();
|
|
7952
|
+
if (remainingMs <= 0) continue;
|
|
7953
|
+
const claimedJob = { ...job, timeoutMs: remainingMs };
|
|
7954
|
+
const heartbeatController = new AbortController();
|
|
7955
|
+
const workController = new AbortController();
|
|
7956
|
+
const heartbeatSignal = AbortSignal.any([signal, heartbeatController.signal]);
|
|
7957
|
+
const workSignal = AbortSignal.any([signal, workController.signal]);
|
|
7958
|
+
let heartbeatError;
|
|
7959
|
+
let completionAccepted = false;
|
|
7960
|
+
const heartbeat = maintainClaim(claimedJob, heartbeatSignal, deadline).catch((error) => {
|
|
7961
|
+
if (heartbeatSignal.aborted || completionAccepted) return;
|
|
7962
|
+
heartbeatError = error;
|
|
7963
|
+
workController.abort();
|
|
7964
|
+
});
|
|
7965
|
+
try {
|
|
7966
|
+
const result = await invoke(claimedJob, workSignal);
|
|
7967
|
+
if (heartbeatError) throw heartbeatError;
|
|
7968
|
+
await complete(claimedJob, result, workSignal, deadline, signal, () => {
|
|
7969
|
+
completionAccepted = true;
|
|
7970
|
+
});
|
|
7971
|
+
if (heartbeatError && !completionAccepted) throw heartbeatError;
|
|
7972
|
+
} catch (error) {
|
|
7973
|
+
log6.warn(`delegate support passport model completion failed: ${String(error)}`);
|
|
7974
|
+
} finally {
|
|
7975
|
+
heartbeatController.abort();
|
|
7976
|
+
workController.abort();
|
|
7977
|
+
await heartbeat;
|
|
7978
|
+
}
|
|
7979
|
+
} catch (error) {
|
|
7980
|
+
if (signal.aborted) break;
|
|
7981
|
+
log6.warn(`delegate support passport model bridge failed: ${String(error)}`);
|
|
7982
|
+
await delayAfterFailure();
|
|
7983
|
+
}
|
|
7984
|
+
}
|
|
7985
|
+
};
|
|
7986
|
+
const run = async (signal) => {
|
|
7987
|
+
await Promise.all(Array.from({ length: MODEL_WORKER_COUNT }, () => runPoller(signal)));
|
|
7988
|
+
};
|
|
7989
|
+
return {
|
|
7990
|
+
id: `${options.serviceId}:support-passport-model`,
|
|
7991
|
+
async start() {
|
|
7992
|
+
if (worker) return;
|
|
7993
|
+
controller = new AbortController();
|
|
7994
|
+
worker = run(controller.signal).finally(() => {
|
|
7995
|
+
worker = void 0;
|
|
7996
|
+
controller = void 0;
|
|
7997
|
+
});
|
|
7998
|
+
},
|
|
7999
|
+
async stop() {
|
|
8000
|
+
controller?.abort();
|
|
8001
|
+
await worker;
|
|
8002
|
+
}
|
|
8003
|
+
};
|
|
8004
|
+
}
|
|
8005
|
+
|
|
7683
8006
|
// src/delegate-runtime.ts
|
|
7684
8007
|
var DELEGATE_BATCH_FLUSH_CACHE_TTL_MS = 3e4;
|
|
8008
|
+
var delegatePassportServiceApiServices = /* @__PURE__ */ new WeakMap();
|
|
7685
8009
|
function sessionKeyFrom(event, ctx) {
|
|
7686
8010
|
const fromCtx = ctx?.sessionKey;
|
|
7687
8011
|
if (typeof fromCtx === "string" && fromCtx.length > 0) return fromCtx;
|
|
@@ -7732,9 +8056,34 @@ function readContextComposition(response, fallbackContext) {
|
|
|
7732
8056
|
function registerDelegateRuntime(api, options) {
|
|
7733
8057
|
const { target, namespace, namespaceBindings } = options;
|
|
7734
8058
|
const now = options.now ?? Date.now;
|
|
8059
|
+
if (options.supportPassportModelRoute) {
|
|
8060
|
+
const registeredServices = delegatePassportServiceApiServices.get(api);
|
|
8061
|
+
if (registeredServices?.has(options.serviceId)) {
|
|
8062
|
+
log7.debug(
|
|
8063
|
+
`delegate register: ${options.serviceId} already has its support passport model service on this api`
|
|
8064
|
+
);
|
|
8065
|
+
} else if (typeof api.registerService !== "function") {
|
|
8066
|
+
log7.error(
|
|
8067
|
+
`[${options.serviceId}] delegate support passport gateway routing is unavailable: host exposes no service registration surface`
|
|
8068
|
+
);
|
|
8069
|
+
} else {
|
|
8070
|
+
api.registerService(
|
|
8071
|
+
createDelegateSupportPassportModelService({
|
|
8072
|
+
serviceId: options.serviceId,
|
|
8073
|
+
target,
|
|
8074
|
+
route: options.supportPassportModelRoute
|
|
8075
|
+
})
|
|
8076
|
+
);
|
|
8077
|
+
const services = registeredServices ?? /* @__PURE__ */ new Set();
|
|
8078
|
+
services.add(options.serviceId);
|
|
8079
|
+
if (registeredServices === void 0) {
|
|
8080
|
+
delegatePassportServiceApiServices.set(api, services);
|
|
8081
|
+
}
|
|
8082
|
+
}
|
|
8083
|
+
}
|
|
7735
8084
|
if (options.passive) {
|
|
7736
|
-
|
|
7737
|
-
`[${options.serviceId}] bridge mode delegate: memory slot not owned \u2014 passive, no hooks registered`
|
|
8085
|
+
log7.info(
|
|
8086
|
+
`[${options.serviceId}] bridge mode delegate: memory slot not owned \u2014 passive, no memory hooks registered`
|
|
7738
8087
|
);
|
|
7739
8088
|
return;
|
|
7740
8089
|
}
|
|
@@ -7802,13 +8151,13 @@ function registerDelegateRuntime(api, options) {
|
|
|
7802
8151
|
const promptRemaining = () => promptDeadline - Date.now();
|
|
7803
8152
|
try {
|
|
7804
8153
|
if (options.shouldSkipRecall(sessionKey)) {
|
|
7805
|
-
|
|
8154
|
+
log7.debug(`delegate recall skipped: cron policy excludes ${sessionKey}`);
|
|
7806
8155
|
return void 0;
|
|
7807
8156
|
}
|
|
7808
8157
|
const runtimeAgent = ctx?.runtime?.agent;
|
|
7809
8158
|
const agentId = (typeof ctx?.agentId === "string" ? ctx.agentId : void 0) ?? (typeof runtimeAgent?.id === "string" ? runtimeAgent.id : void 0) ?? "main";
|
|
7810
8159
|
if (await options.resolveSessionDisabled(sessionKey, agentId)) {
|
|
7811
|
-
|
|
8160
|
+
log7.debug(`delegate recall skipped: session toggle disables memory for ${sessionKey}`);
|
|
7812
8161
|
return void 0;
|
|
7813
8162
|
}
|
|
7814
8163
|
const cwd = cwdFrom(event, ctx, options.cwd);
|
|
@@ -7855,7 +8204,7 @@ function registerDelegateRuntime(api, options) {
|
|
|
7855
8204
|
}
|
|
7856
8205
|
return { prependSystemContext: prompt };
|
|
7857
8206
|
} catch (err) {
|
|
7858
|
-
|
|
8207
|
+
log7.warn(`delegate recall failed: ${String(err)}`);
|
|
7859
8208
|
return void 0;
|
|
7860
8209
|
}
|
|
7861
8210
|
};
|
|
@@ -7877,7 +8226,7 @@ function registerDelegateRuntime(api, options) {
|
|
|
7877
8226
|
api.registerMemoryPromptSection(memoryBuildFn);
|
|
7878
8227
|
}
|
|
7879
8228
|
} else {
|
|
7880
|
-
|
|
8229
|
+
log7.info(
|
|
7881
8230
|
`[${options.serviceId}] bridge mode delegate: prompt injection disabled by hooks policy`
|
|
7882
8231
|
);
|
|
7883
8232
|
}
|
|
@@ -7923,7 +8272,7 @@ function registerDelegateRuntime(api, options) {
|
|
|
7923
8272
|
Math.max(1, observeRemaining())
|
|
7924
8273
|
);
|
|
7925
8274
|
} catch (err) {
|
|
7926
|
-
|
|
8275
|
+
log7.warn(`delegate observe failed: ${String(err)}`);
|
|
7927
8276
|
}
|
|
7928
8277
|
});
|
|
7929
8278
|
let cachedBatchFlushSupport;
|
|
@@ -7977,7 +8326,7 @@ function registerDelegateRuntime(api, options) {
|
|
|
7977
8326
|
const remainingBudget = () => deadline - Date.now();
|
|
7978
8327
|
const sessionKey = lifecycleSessionKeyFrom(event, ctx);
|
|
7979
8328
|
if (sessionKey === void 0) {
|
|
7980
|
-
|
|
8329
|
+
log7.warn("delegate flush skipped: lifecycle event has malformed session key");
|
|
7981
8330
|
return false;
|
|
7982
8331
|
}
|
|
7983
8332
|
const namespaces = await lifecycleSessionNamespacesFrom(
|
|
@@ -8002,7 +8351,7 @@ function registerDelegateRuntime(api, options) {
|
|
|
8002
8351
|
remainingTimeoutMs: remainingBudget
|
|
8003
8352
|
});
|
|
8004
8353
|
} catch (err) {
|
|
8005
|
-
|
|
8354
|
+
log7.warn(`delegate flush-plan ingestion failed: ${String(err)}`);
|
|
8006
8355
|
}
|
|
8007
8356
|
const flushNamespace = async (sessionNamespace) => postJson(
|
|
8008
8357
|
target,
|
|
@@ -8072,7 +8421,7 @@ function registerDelegateRuntime(api, options) {
|
|
|
8072
8421
|
}
|
|
8073
8422
|
return flushIndividually();
|
|
8074
8423
|
} catch (err) {
|
|
8075
|
-
|
|
8424
|
+
log7.warn(`delegate flush failed: ${String(err)}`);
|
|
8076
8425
|
return false;
|
|
8077
8426
|
}
|
|
8078
8427
|
};
|
|
@@ -8082,7 +8431,7 @@ function registerDelegateRuntime(api, options) {
|
|
|
8082
8431
|
api.on("before_reset", flushEndedSession);
|
|
8083
8432
|
api.on("session_end", flushEndedSession);
|
|
8084
8433
|
}
|
|
8085
|
-
|
|
8434
|
+
log7.info(
|
|
8086
8435
|
`[${options.serviceId}] bridge mode delegate: memory loop backed by daemon at ${target.host}:${target.port} (embedded orchestrator skipped; tools/CLI stay daemon-side)`
|
|
8087
8436
|
);
|
|
8088
8437
|
}
|
|
@@ -8139,7 +8488,7 @@ function createDelegateNamespaceBindingStore(memoryDir, serviceId, isLegacyAdapt
|
|
|
8139
8488
|
return previous;
|
|
8140
8489
|
} catch (err) {
|
|
8141
8490
|
if (current.length > 0) {
|
|
8142
|
-
|
|
8491
|
+
log7.warn(
|
|
8143
8492
|
`[${serviceId}] delegate legacy namespace read failed; using canonical bindings: ${String(err)}`
|
|
8144
8493
|
);
|
|
8145
8494
|
return [];
|
|
@@ -8170,7 +8519,7 @@ function createDelegateNamespaceBindingStore(memoryDir, serviceId, isLegacyAdapt
|
|
|
8170
8519
|
try {
|
|
8171
8520
|
await legacy.replace?.(sessionKey, []);
|
|
8172
8521
|
} catch (err) {
|
|
8173
|
-
|
|
8522
|
+
log7.warn(`[${serviceId}] delegate legacy namespace cleanup failed: ${String(err)}`);
|
|
8174
8523
|
}
|
|
8175
8524
|
}
|
|
8176
8525
|
rememberMigratedLegacySession(sessionKey);
|
|
@@ -8191,7 +8540,7 @@ function createDelegateNamespaceBindingStore(memoryDir, serviceId, isLegacyAdapt
|
|
|
8191
8540
|
await persistNamespaceHistory(primary, sessionKey, merged);
|
|
8192
8541
|
await completeLegacyMigration(sessionKey);
|
|
8193
8542
|
} catch (err) {
|
|
8194
|
-
|
|
8543
|
+
log7.warn(`[${serviceId}] delegate namespace migration failed: ${String(err)}`);
|
|
8195
8544
|
}
|
|
8196
8545
|
return merged;
|
|
8197
8546
|
});
|
|
@@ -8219,13 +8568,13 @@ var delegateAuthorizationPreflightServices = /* @__PURE__ */ new WeakMap();
|
|
|
8219
8568
|
function maybeRegisterDelegateRuntime(api, options, deps = { checkHealth: checkDaemonHealthSync }) {
|
|
8220
8569
|
const boundServices = delegateHookApiServices.get(api);
|
|
8221
8570
|
if (boundServices?.has(options.serviceId)) {
|
|
8222
|
-
|
|
8571
|
+
log7.debug(
|
|
8223
8572
|
`delegate register: ${options.serviceId} already has hooks bound on this api \u2014 skipping duplicate registration`
|
|
8224
8573
|
);
|
|
8225
8574
|
return true;
|
|
8226
8575
|
}
|
|
8227
8576
|
if (delegateEmbeddedFallbackApis.has(api)) {
|
|
8228
|
-
|
|
8577
|
+
log7.debug(
|
|
8229
8578
|
`delegate register: ${options.serviceId} previously fell back to embedded on this api \u2014 staying embedded to avoid stacking memory paths`
|
|
8230
8579
|
);
|
|
8231
8580
|
return false;
|
|
@@ -8239,11 +8588,11 @@ function maybeRegisterDelegateRuntime(api, options, deps = { checkHealth: checkD
|
|
|
8239
8588
|
bridge = resolveBridgeMode(options.configBridgeMode, {
|
|
8240
8589
|
memoryDir: options.memoryDir,
|
|
8241
8590
|
timeoutMs: bridgeHealthTimeoutMs,
|
|
8242
|
-
onSkip: (reason) =>
|
|
8591
|
+
onSkip: (reason) => log7.info(`[${options.serviceId}] bridge mode auto: staying embedded \u2014 ${reason}`)
|
|
8243
8592
|
});
|
|
8244
8593
|
} catch (err) {
|
|
8245
8594
|
const wantedDelegate = requestedDelegate(options.configBridgeMode);
|
|
8246
|
-
|
|
8595
|
+
log7.error(
|
|
8247
8596
|
wantedDelegate ? `${String(err)} \u2014 falling back to the embedded runtime` : `${String(err)} \u2014 the deployment is embedded, so this only affects delegate mode`
|
|
8248
8597
|
);
|
|
8249
8598
|
if (!options.passive) delegateEmbeddedFallbackApis.add(api);
|
|
@@ -8251,7 +8600,7 @@ function maybeRegisterDelegateRuntime(api, options, deps = { checkHealth: checkD
|
|
|
8251
8600
|
}
|
|
8252
8601
|
if (bridge.mode !== "delegate") {
|
|
8253
8602
|
if (delegateBoundApis.has(api)) {
|
|
8254
|
-
|
|
8603
|
+
log7.warn(
|
|
8255
8604
|
`[${options.serviceId}] bridge mode resolved embedded, but a sibling service already bound delegate hooks on this api \u2014 reusing them instead of stacking an embedded runtime`
|
|
8256
8605
|
);
|
|
8257
8606
|
return true;
|
|
@@ -8259,7 +8608,7 @@ function maybeRegisterDelegateRuntime(api, options, deps = { checkHealth: checkD
|
|
|
8259
8608
|
if (!options.passive) {
|
|
8260
8609
|
delegateEmbeddedFallbackApis.add(api);
|
|
8261
8610
|
if (resolveRequestedBridgeMode(options.configBridgeMode) === "auto") {
|
|
8262
|
-
|
|
8611
|
+
log7.info(
|
|
8263
8612
|
`[${options.serviceId}] bridge mode auto: embedded hooks are bound on this api \u2014 a daemon that starts later is picked up on the next gateway restart`
|
|
8264
8613
|
);
|
|
8265
8614
|
}
|
|
@@ -8268,13 +8617,13 @@ function maybeRegisterDelegateRuntime(api, options, deps = { checkHealth: checkD
|
|
|
8268
8617
|
}
|
|
8269
8618
|
if (!bridge.healthVerified && !deps.checkHealth(bridge.daemonHost, bridge.daemonPort, bridgeHealthTimeoutMs)) {
|
|
8270
8619
|
if (delegateBoundApis.has(api)) {
|
|
8271
|
-
|
|
8620
|
+
log7.warn(
|
|
8272
8621
|
`[${options.serviceId}] no healthy daemon at ${bridge.daemonHost}:${bridge.daemonPort}, but a sibling service already bound delegate hooks on this api \u2014 reusing them instead of stacking an embedded runtime`
|
|
8273
8622
|
);
|
|
8274
8623
|
return true;
|
|
8275
8624
|
}
|
|
8276
8625
|
delegateEmbeddedFallbackApis.add(api);
|
|
8277
|
-
|
|
8626
|
+
log7.error(
|
|
8278
8627
|
`bridge mode delegate requested but no healthy daemon at ${bridge.daemonHost}:${bridge.daemonPort} \u2014 falling back to the embedded runtime`
|
|
8279
8628
|
);
|
|
8280
8629
|
return false;
|
|
@@ -8316,7 +8665,8 @@ function maybeRegisterDelegateRuntime(api, options, deps = { checkHealth: checkD
|
|
|
8316
8665
|
capability: options.capability,
|
|
8317
8666
|
recallTimeoutMs: 25e3,
|
|
8318
8667
|
observeTimeoutMs: 12e4,
|
|
8319
|
-
flushTimeoutMs: 55e3
|
|
8668
|
+
flushTimeoutMs: 55e3,
|
|
8669
|
+
supportPassportModelRoute: options.supportPassportModelRoute
|
|
8320
8670
|
});
|
|
8321
8671
|
let preflightServices = delegateAuthorizationPreflightServices.get(api);
|
|
8322
8672
|
if (!options.passive && !preflightServices?.has(options.serviceId)) {
|
|
@@ -8331,16 +8681,16 @@ function maybeRegisterDelegateRuntime(api, options, deps = { checkHealth: checkD
|
|
|
8331
8681
|
void probe(target, "", operations).then((result) => {
|
|
8332
8682
|
if (result.state === "authorized") return;
|
|
8333
8683
|
if (result.state === "unauthorized") {
|
|
8334
|
-
|
|
8684
|
+
log7.warn(
|
|
8335
8685
|
`delegate authorization preflight rejected ${operationLabel} (${result.status}; token source: ${result.tokenSource}) \u2014 runtime remains active`
|
|
8336
8686
|
);
|
|
8337
8687
|
return;
|
|
8338
8688
|
}
|
|
8339
|
-
|
|
8689
|
+
log7.warn(
|
|
8340
8690
|
`delegate authorization preflight could not verify ${operationLabel} (token source: ${result.tokenSource}) \u2014 runtime remains active`
|
|
8341
8691
|
);
|
|
8342
8692
|
}).catch(() => {
|
|
8343
|
-
|
|
8693
|
+
log7.warn("delegate authorization preflight could not complete \u2014 runtime remains active");
|
|
8344
8694
|
});
|
|
8345
8695
|
}
|
|
8346
8696
|
return true;
|
|
@@ -9349,6 +9699,7 @@ var pluginDefinition = {
|
|
|
9349
9699
|
}
|
|
9350
9700
|
);
|
|
9351
9701
|
const delegateApi = api;
|
|
9702
|
+
const delegateSupportPassportGatewayRoute = createConfiguredSupportPassportGatewayRoute(cfg);
|
|
9352
9703
|
const delegateHandled = maybeRegisterDelegateRuntime(delegateApi, {
|
|
9353
9704
|
serviceId,
|
|
9354
9705
|
configBridgeMode: cfg.bridgeMode,
|
|
@@ -9367,6 +9718,7 @@ var pluginDefinition = {
|
|
|
9367
9718
|
shouldSkipRecall: (sk) => shouldSkipRecallForSession(sk, cfg),
|
|
9368
9719
|
cwd: getOpenClawRuntimeWorkspaceDir(api),
|
|
9369
9720
|
flushOnResetEnabled: cfg.flushOnResetEnabled,
|
|
9721
|
+
supportPassportModelRoute: delegateSupportPassportGatewayRoute ?? void 0,
|
|
9370
9722
|
// Memory-slot capability inputs. Mirrors the embedded derivation: the
|
|
9371
9723
|
// registration-time runtime agent owns this memory, and QMD is the
|
|
9372
9724
|
// backend only when it is both selected and enabled.
|
|
@@ -9434,7 +9786,7 @@ var pluginDefinition = {
|
|
|
9434
9786
|
globalThis.__openclawEngramTrace = void 0;
|
|
9435
9787
|
}
|
|
9436
9788
|
const existingAccessService = globalThis[keys.ACCESS_SERVICE];
|
|
9437
|
-
const accessService = existingAccessService && existingAccessService ? existingAccessService : new
|
|
9789
|
+
const accessService = existingAccessService && existingAccessService ? existingAccessService : new EngramAccessService(orchestrator, {
|
|
9438
9790
|
resolveSecretRef: (ref, context) => loadOpenClawSecretRefResolver().then((resolver) => resolver ? resolver(ref, context) : void 0)
|
|
9439
9791
|
});
|
|
9440
9792
|
globalThis[keys.ACCESS_SERVICE] = accessService;
|
|
@@ -9680,9 +10032,9 @@ Keep the reflection grounded in the evidence below.
|
|
|
9680
10032
|
let rawNarrative = "";
|
|
9681
10033
|
try {
|
|
9682
10034
|
if (route.kind === "gateway") {
|
|
9683
|
-
const llm = new
|
|
10035
|
+
const llm = new FallbackLlmClient2(
|
|
9684
10036
|
cfg.gatewayConfig,
|
|
9685
|
-
|
|
10037
|
+
fallbackLlmRuntimeContextFromConfig2(cfg)
|
|
9686
10038
|
);
|
|
9687
10039
|
if (!route.hasExplicitModel && !llm.isAvailable(route.options)) {
|
|
9688
10040
|
logger_exports.log.debug(
|
|
@@ -12145,6 +12497,7 @@ var export_loadDaySummaryPrompt = day_summary_exports.loadDaySummaryPrompt;
|
|
|
12145
12497
|
export {
|
|
12146
12498
|
buildHourlySummaryCronJob,
|
|
12147
12499
|
checkDaemonHealth,
|
|
12500
|
+
createOpenClawSupportPassportModelRoute,
|
|
12148
12501
|
src_default as default,
|
|
12149
12502
|
detectBridgeMode,
|
|
12150
12503
|
detectDaemonBridgeMode,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PluginConfig, SupportPassportModelRoute } from '@remnic/core';
|
|
2
|
+
import { FallbackLlmClient } from '@remnic/core/fallback-llm';
|
|
3
|
+
|
|
4
|
+
type SupportPassportGatewayConfig = Pick<PluginConfig, "modelSource" | "taskModelChain" | "gatewayAgentId" | "gatewayConfig">;
|
|
5
|
+
declare function createOpenClawSupportPassportModelRoute(config: SupportPassportGatewayConfig, client: Pick<FallbackLlmClient, "chatCompletion">): SupportPassportModelRoute;
|
|
6
|
+
|
|
7
|
+
export { createOpenClawSupportPassportModelRoute };
|