refactor(subagent): split extension into modules
This commit is contained in:
21
src/session.ts
Normal file
21
src/session.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
|
||||
// Session Path - Persist child sessions as <agent>_<uuid>.jsonl under a cwd hash.
|
||||
export function getSubagentSessionPath(
|
||||
cwd: string,
|
||||
agentName: string,
|
||||
sessionId: string,
|
||||
): string {
|
||||
const cwdHash = createHash("sha256").update(cwd).digest("hex").slice(0, 16);
|
||||
const safeAgent = agentName.replace(/[^\w.-]+/g, "_");
|
||||
const safeSessionId = sessionId.replace(/[^\w.-]+/g, "_");
|
||||
return path.join(
|
||||
os.homedir(),
|
||||
".pi",
|
||||
"subagent-sessions",
|
||||
cwdHash,
|
||||
`${safeAgent}_${safeSessionId}.jsonl`,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user