fix: show deployed sandbox agent identity (#44)
Co-authored-by: mmckeen-nv <mmckeen-nv@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
normalizeAgentIdentifier,
|
||||
parseNemoclawListJson,
|
||||
resolveSandboxAgent,
|
||||
} from '../app/lib/nemoclawIdentity.mjs'
|
||||
|
||||
const jsonInventory = JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
sandboxes: [
|
||||
{ name: 'my-hermes', agent: 'Hermes', isDefault: true },
|
||||
{ name: 'gateway-recovered', agent: 'unknown', isDefault: false },
|
||||
{ name: 'custom-agent', agent: 'LangChain DeepAgents Code', isDefault: false },
|
||||
],
|
||||
})
|
||||
|
||||
const parsed = parseNemoclawListJson(jsonInventory)
|
||||
assert.ok(parsed, 'schemaVersion=1 NemoClaw JSON inventory should parse')
|
||||
assert.deepEqual(parsed.defaultSandboxNames, ['my-hermes'])
|
||||
assert.equal(parsed.agentsByName['my-hermes'], 'hermes')
|
||||
assert.equal(parsed.agentsByName['gateway-recovered'], 'unknown')
|
||||
assert.equal(parsed.agentsByName['custom-agent'], 'langchain-deepagents-code')
|
||||
|
||||
assert.equal(resolveSandboxAgent('my-hermes', null, parsed, null), 'hermes')
|
||||
assert.equal(resolveSandboxAgent('gateway-recovered', null, parsed, null), 'unknown')
|
||||
assert.equal(resolveSandboxAgent('missing-from-json', null, parsed, null), 'unknown')
|
||||
|
||||
assert.equal(normalizeAgentIdentifier('OpenClaw'), 'openclaw')
|
||||
assert.equal(normalizeAgentIdentifier('nemohermes'), 'hermes')
|
||||
assert.equal(normalizeAgentIdentifier('unknown'), 'unknown')
|
||||
|
||||
const legacyRegistry = {
|
||||
sandboxes: {
|
||||
'legacy-null-agent': { name: 'legacy-null-agent', agent: null },
|
||||
'explicit-hermes': { name: 'explicit-hermes', agent: 'Hermes' },
|
||||
'explicit-unknown': { name: 'explicit-unknown', agent: 'unknown' },
|
||||
},
|
||||
}
|
||||
|
||||
assert.equal(resolveSandboxAgent('legacy-null-agent', null, null, legacyRegistry), 'openclaw')
|
||||
assert.equal(resolveSandboxAgent('explicit-hermes', null, null, legacyRegistry), 'hermes')
|
||||
assert.equal(resolveSandboxAgent('explicit-unknown', null, null, legacyRegistry), 'unknown')
|
||||
|
||||
assert.equal(parseNemoclawListJson('{'), null, 'invalid JSON must fail closed')
|
||||
assert.equal(parseNemoclawListJson(JSON.stringify({ schemaVersion: 2, sandboxes: [] })), null, 'unsupported schema versions must fail closed')
|
||||
|
||||
console.log('nemoclaw-identity-resolution-check: PASS json identity resolution assertions')
|
||||
@@ -190,7 +190,7 @@ assert.doesNotMatch(deleteRouteSource, /Pruned NemoClaw registry entry without d
|
||||
assert.match(deleteRouteSource, /openShellAlreadyGone/, 'delete route must tolerate sandboxes that OpenShell already deleted while NemoClaw still has registry state')
|
||||
assert.doesNotMatch(deleteRouteSource, /isGatewayRecoverable|recoverableGateway/, 'delete route must not include the later gateway-repair branching')
|
||||
assert.match(telemetryRouteSource, /const names = parseOpenShellSandboxNames\(sandboxListStdout\)/, 'telemetry must derive inventory from OpenShell before consulting NemoClaw')
|
||||
assert.match(telemetryRouteSource, /names\.length > 0[\s\S]*execNemoclaw\(\["list"\]\)[\s\S]*execNemoclaw\(\["status"\]\)/, 'telemetry must skip NemoClaw list/status when OpenShell reports zero live sandboxes')
|
||||
assert.match(telemetryRouteSource, /names\.length > 0[\s\S]*execNemoclaw\(\["status"\]\)[\s\S]*execNemoclaw\(\["list", "--json"\]\)/, 'telemetry must skip NemoClaw list/status when OpenShell reports zero live sandboxes and prefer nemoclaw list --json when sandboxes exist')
|
||||
assert.match(telemetryRouteSource, /readNemoClawRegistry/, 'telemetry must read the NemoClaw registry for agent metadata')
|
||||
assert.match(telemetryRouteSource, /resolveSandboxAgent/, 'telemetry must resolve OpenClaw versus Hermes agent metadata')
|
||||
assert.match(telemetryRouteSource, /"nemoclaw\.ai\/agent": agent/, 'telemetry pod labels must include the selected NemoClaw agent')
|
||||
@@ -200,7 +200,7 @@ assert.match(sandboxListSource, /function displaySandboxAgent\(agent\?: string\)
|
||||
assert.match(sandboxListSource, /function SandboxTypeLogo\(\{ agent \}/, 'sandbox list must render per-agent sandbox logos')
|
||||
assert.match(sandboxListSource, /const OPENCLAW_SANDBOX_LOGO = '\/sandbox-logos\/openclaw\.svg'/, 'OpenClaw sandboxes must use the local OpenClaw favicon asset')
|
||||
assert.match(sandboxListSource, /const HERMES_SANDBOX_LOGO = '\/sandbox-logos\/hermes\.png'/, 'Hermes sandboxes must use the local Hermes favicon asset')
|
||||
assert.match(sandboxListSource, /const logoSrc = isHermes \? HERMES_SANDBOX_LOGO : OPENCLAW_SANDBOX_LOGO/, 'sandbox type logo must switch assets by agent type')
|
||||
assert.match(sandboxListSource, /const logoSrc = isHermes \? HERMES_SANDBOX_LOGO : isOpenClaw \? OPENCLAW_SANDBOX_LOGO : null/, 'sandbox type logo must avoid misclassifying unknown agents as OpenClaw')
|
||||
assert.ok(openClawLogoStat.size > 0, 'OpenClaw favicon asset must be vendored locally')
|
||||
assert.ok(hermesLogoStat.size > 0, 'Hermes favicon asset must be vendored locally')
|
||||
assert.match(sandboxListSource, /selectedSandbox\?\.agent === 'hermes'/, 'sandbox operations must detect Hermes sandboxes')
|
||||
|
||||
Reference in New Issue
Block a user