mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-06-02 23:23:45 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { resolveAgentWorkspaceDir } from "../../agents/agent-scope.js";
|
|
import type { OpenClawConfig } from "../../config/config.js";
|
|
import { loadSessionStore, resolveStorePath } from "../../config/sessions.js";
|
|
import { listGatewayAgentsBasic } from "../../gateway/agent-list.js";
|
|
|
|
async function fileExists(p: string): Promise<boolean> {
|
|
try {
|
|
await fs.access(p);
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export async function getAgentLocalStatuses(cfg: OpenClawConfig) {
|
|
const agentList = listGatewayAgentsBasic(cfg);
|
|
const now = Date.now();
|
|
|
|
const agents = await Promise.all(
|
|
agentList.agents.map(async (agent) => {
|
|
const workspaceDir = (() => {
|
|
try {
|
|
return resolveAgentWorkspaceDir(cfg, agent.id);
|
|
} catch {
|
|
return null;
|
|
}
|
|
})();
|
|
const bootstrapPending =
|
|
workspaceDir != null ? await fileExists(path.join(workspaceDir, "BOOTSTRAP.md")) : null;
|
|
const sessionsPath = resolveStorePath(cfg.session?.store, {
|
|
agentId: agent.id,
|
|
});
|
|
const store = (() => {
|
|
try {
|
|
return loadSessionStore(sessionsPath);
|
|
} catch {
|
|
return {};
|
|
}
|
|
})();
|
|
const updatedAt = Object.values(store).reduce(
|
|
(max, entry) => Math.max(max, entry?.updatedAt ?? 0),
|
|
0,
|
|
);
|
|
const lastUpdatedAt = updatedAt > 0 ? updatedAt : null;
|
|
const lastActiveAgeMs = lastUpdatedAt ? now - lastUpdatedAt : null;
|
|
const sessionsCount = Object.keys(store).filter(
|
|
(k) => k !== "global" && k !== "unknown",
|
|
).length;
|
|
return {
|
|
id: agent.id,
|
|
name: agent.name,
|
|
workspaceDir,
|
|
bootstrapPending,
|
|
sessionsPath,
|
|
sessionsCount,
|
|
lastUpdatedAt,
|
|
lastActiveAgeMs,
|
|
};
|
|
}),
|
|
);
|
|
|
|
const totalSessions = agents.reduce((sum, a) => sum + a.sessionsCount, 0);
|
|
const bootstrapPendingCount = agents.reduce((sum, a) => sum + (a.bootstrapPending ? 1 : 0), 0);
|
|
return {
|
|
defaultId: agentList.defaultId,
|
|
agents,
|
|
totalSessions,
|
|
bootstrapPendingCount,
|
|
};
|
|
}
|