MCPcopy Create free account
hub / github.com/cortexkit/magic-context / buildStatusDetail

Function buildStatusDetail

packages/plugin/src/plugin/rpc-handlers.ts:494–671  ·  view source on GitHub ↗
(
    db: Database,
    sessionId: string,
    directory: string,
    modelKey?: string,
    config?: Record<string, unknown>,
    liveSessionState?: LiveSessionState,
    injectionBudgetTokens?: number,
)

Source from the content-addressed store, hash-verified

492}
493
494export function buildStatusDetail(
495 db: Database,
496 sessionId: string,
497 directory: string,
498 modelKey?: string,
499 config?: Record<string, unknown>,
500 liveSessionState?: LiveSessionState,
501 injectionBudgetTokens?: number,
502): StatusDetail {
503 const base = buildSidebarSnapshot(
504 db,
505 sessionId,
506 directory,
507 liveSessionState,
508 injectionBudgetTokens,
509 config,
510 );
511 const detail: StatusDetail = {
512 ...base,
513 tagCounter: 0,
514 activeTags: 0,
515 droppedTags: 0,
516 totalTags: 0,
517 activeBytes: 0,
518 lastResponseTime: 0,
519 lastNudgeTokens: 0,
520 lastTransformError: null,
521 isSubagent: false,
522 pendingOps: [],
523 contextLimit: 0,
524 cacheTtlMs: 0,
525 cacheRemainingMs: 0,
526 cacheExpired: false,
527 executeThreshold: 65,
528 executeThresholdMode: "percentage",
529 protectedTagCount: 20,
530 historyBudgetPercentage: 0.15,
531 historyBlockTokens: 0,
532 compressionBudget: null,
533 compressionUsage: null,
534 toastDurationMs: 5000,
535 };
536
537 try {
538 const meta = db
539 .prepare<[string], Record<string, unknown>>(
540 "SELECT * FROM session_meta WHERE session_id = ?",
541 )
542 .get(sessionId);
543 if (meta) {
544 detail.tagCounter = Number(meta.counter ?? 0);
545 detail.lastResponseTime = Number(meta.last_response_time ?? 0);
546 detail.lastNudgeTokens = Number(meta.last_nudge_tokens ?? 0);
547 detail.lastTransformError = meta.last_transform_error
548 ? String(meta.last_transform_error)
549 : null;
550 detail.isSubagent = Boolean(meta.is_subagent);
551 }

Callers 2

registerRpcHandlersFunction · 0.85

Calls 7

logFunction · 0.90
buildSidebarSnapshotFunction · 0.85
resolveConfigValueFunction · 0.85
getMethod · 0.80
parseTtlStringFunction · 0.70
prepareMethod · 0.45

Tested by

no test coverage detected