MCPcopy Create free account
hub / github.com/Noumena-Network/code / getInitialState

Function getInitialState

src/bootstrap/state.ts:265–432  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

263
264// ALSO HERE - THINK THRICE BEFORE MODIFYING
265function getInitialState(): State {
266 // Resolve symlinks in cwd to match behavior of shell.ts setCwd
267 // This ensures consistency with how paths are sanitized for session storage
268 let resolvedCwd = ''
269 if (
270 typeof process !== 'undefined' &&
271 typeof process.cwd === 'function' &&
272 typeof realpathSync === 'function'
273 ) {
274 const rawCwd = cwd()
275 try {
276 resolvedCwd = realpathSync(rawCwd).normalize('NFC')
277 } catch {
278 // File Provider EPERM on CloudStorage mounts (lstat per path component).
279 resolvedCwd = rawCwd.normalize('NFC')
280 }
281 }
282 const state: State = {
283 originalCwd: resolvedCwd,
284 projectRoot: resolvedCwd,
285 totalCostUSD: 0,
286 totalAPIDuration: 0,
287 totalAPIDurationWithoutRetries: 0,
288 totalToolDuration: 0,
289 turnHookDurationMs: 0,
290 turnToolDurationMs: 0,
291 turnClassifierDurationMs: 0,
292 turnToolCount: 0,
293 turnHookCount: 0,
294 turnClassifierCount: 0,
295 startTime: Date.now(),
296 lastInteractionTime: Date.now(),
297 totalLinesAdded: 0,
298 totalLinesRemoved: 0,
299 hasUnknownModelCost: false,
300 cwd: resolvedCwd,
301 modelUsage: {},
302 mainLoopModelOverride: undefined,
303 initialMainLoopModel: null,
304 modelStrings: null,
305 isInteractive: false,
306 kairosActive: false,
307 strictToolResultPairing: false,
308 sdkAgentProgressSummariesEnabled: false,
309 userMsgOptIn: false,
310 clientType: 'cli',
311 sessionSource: undefined,
312 questionPreviewFormat: undefined,
313 sessionIngressToken: undefined,
314 oauthTokenFromFd: undefined,
315 apiKeyFromFd: undefined,
316 flagSettingsPath: undefined,
317 flagSettingsInline: null,
318 allowedSettingSources: [
319 'userSettings',
320 'projectSettings',
321 'localSettings',
322 'flagSettings',

Callers 2

state.tsFile · 0.85
resetStateForTestsFunction · 0.85

Calls 4

realpathSyncFunction · 0.90
randomUUIDFunction · 0.90
cwdFunction · 0.85
isInternalBuildFunction · 0.85

Tested by

no test coverage detected