MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / readImportedDetail

Function readImportedDetail

apps/vis/server/src/lib/session-store.ts:92–111  ·  view source on GitHub ↗

Detail for an imported bundle. Same readers as a local session, but the * directory is `imported/ /`, the workDir comes from the manifest, and * agent homedirs are re-derived from the local extraction (state.json holds * the exporting machine's absolute paths, which do not exist here). The

(home: string, importId: string)

Source from the content-addressed store, hash-verified

90 * `imported_from_kimi_cli` hide-filter is intentionally NOT applied — the
91 * user imported this bundle deliberately. */
92async function readImportedDetail(home: string, importId: string): Promise<SessionDetail | null> {
93 const sessionDir = importedDirOf(home, importId);
94 if (!(await pathExists(sessionDir))) return null;
95 const meta = await readImportMeta(home, importId);
96 const workDir = meta?.manifest?.workspaceDir ?? '';
97 const state = await readState(sessionDir);
98 if (state === null) {
99 const agents = await discoverAgentsFromDisk(sessionDir);
100 return { sessionId: importId, sessionDir, workDir, state: null, agents, imported: true, importMeta: meta };
101 }
102 // State is best-effort in a bundle: a readable state.json may still omit the
103 // `agents` map. When the inventory comes back empty, fall back to probing
104 // `agents/*` on disk so routes that require an agent (wire/context/…) still
105 // resolve `main`.
106 let agents = await inventoryAgents(sessionDir, state, true);
107 if (agents.length === 0) {
108 agents = await discoverAgentsFromDisk(sessionDir);
109 }
110 return { sessionId: importId, sessionDir, workDir, state, agents, imported: true, importMeta: meta };
111}
112
113/** Fallback inventory used when `state.json` is unreadable: walk
114 * `<sessionDir>/agents/*` directly and synthesize minimal AgentInfo

Callers 1

readSessionDetailFunction · 0.85

Calls 6

importedDirOfFunction · 0.90
readImportMetaFunction · 0.90
readStateFunction · 0.85
discoverAgentsFromDiskFunction · 0.85
inventoryAgentsFunction · 0.85
pathExistsFunction · 0.70

Tested by

no test coverage detected