openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
50 lines (49 loc) • 1.87 kB
JavaScript
import { r as isIncognitoSessionKey } from "./session-key-CmZ4o9-l.mjs";
import "./session-key-DY3MOX4N.mjs";
import { r as resolveAgentMainSessionKey } from "./main-session-BOUJdkxQ.mjs";
import { t as withPreparedSessionResolve } from "./sessions-resolve-Cs7Lr2I9.mjs";
//#region src/gateway/control-ui-session-path-resolve.ts
/** Both HTTP readers use the same URL grammar and the existing session resolution owner. */
async function resolveControlUiSessionPath(params) {
const { target, projection } = params;
if (params.publicOnly && target.kind !== "main" && isIncognitoSessionKey(target.kind === "short" ? target.literalSessionKey : target.sessionKey)) return null;
let revision;
const resolve = (p) => withPreparedSessionResolve({
projection,
client: params.client,
isCurrent: params.isCurrent,
p: {
...p,
agentId: target.agentId,
allowMissing: true,
includeGlobal: true,
includeUnknown: true
},
publicOnly: params.publicOnly
}, (result) => {
revision = projection.sharingRevision;
return result;
});
let result;
if (target.kind === "main") result = await resolve({ key: resolveAgentMainSessionKey({
cfg: projection.state.cfg,
agentId: target.agentId
}) });
else if (target.kind === "short") {
result = await resolve({
shortId: target.shortId,
slugHint: target.slugHint
});
if (result.ok && "missing" in result) result = await resolve({ reference: { key: target.literalSessionKey } });
} else result = await resolve({ reference: {
key: target.sessionKey,
...target.slugCandidate ? { slug: target.slugCandidate } : {}
} });
return result.ok && "key" in result ? {
key: result.key,
agentId: result.agentId,
isCurrent: () => revision !== void 0 && revision === projection.sharingRevision && params.isCurrent?.() !== false
} : null;
}
//#endregion
export { resolveControlUiSessionPath as t };