MCPcopy Create free account
hub / github.com/MarsWang42/Awel / initSession

Function initSession

packages/cli/src/session.ts:61–80  ·  view source on GitHub ↗
(projectCwd: string)

Source from the content-addressed store, hash-verified

59 * Must be called before the server starts.
60 */
61export function initSession(projectCwd: string): void {
62 _projectCwd = projectCwd;
63 const filePath = sessionPath();
64 if (!filePath || !existsSync(filePath)) return;
65 try {
66 const raw = readFileSync(filePath, 'utf-8');
67 const persisted: PersistedSession = JSON.parse(raw);
68 if (persisted.modelId && persisted.modelProvider && Array.isArray(persisted.messages)) {
69 const { provider } = resolveProvider(persisted.modelId, persisted.modelProvider);
70 session = {
71 modelId: persisted.modelId,
72 modelProvider: persisted.modelProvider,
73 provider,
74 messages: persisted.messages,
75 };
76 }
77 } catch {
78 // Corrupt file — start fresh
79 }
80}
81
82/**
83 * Returns the existing session if the model matches, otherwise creates a new

Callers 1

index.tsFile · 0.85

Calls 2

sessionPathFunction · 0.85
resolveProviderFunction · 0.85

Tested by

no test coverage detected