@codemoot/core 0.2.13 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1781,17 +1781,6 @@ interface SessionEvent {
1781
1781
  codexThreadId: string | null;
1782
1782
  createdAt: number;
1783
1783
  }
1784
- interface SessionOverflowStatus {
1785
- /** Cumulative tokens (for cost tracking). */
1786
- cumulativeTokens: number;
1787
- /** Latest turn's input_tokens (best proxy for current context fullness). */
1788
- lastTurnInputTokens: number;
1789
- maxContext: number;
1790
- /** Based on lastTurnInputTokens / maxContext. */
1791
- utilizationRatio: number;
1792
- shouldWarn: boolean;
1793
- shouldReconstruct: boolean;
1794
- }
1795
1784
  declare class SessionManager {
1796
1785
  private db;
1797
1786
  constructor(db: Database.Database);
@@ -1803,8 +1792,8 @@ declare class SessionManager {
1803
1792
  getActive(): UnifiedSession | null;
1804
1793
  /** Get or create the active session. If none exists, auto-create one. */
1805
1794
  resolveActive(autoName?: string): UnifiedSession;
1806
- /** Update the codex thread ID for a session (after first GPT call). */
1807
- updateThreadId(sessionId: string, threadId: string): void;
1795
+ /** Update the codex thread ID for a session. Pass null to clear. */
1796
+ updateThreadId(sessionId: string, threadId: string | null): void;
1808
1797
  /** Update token usage for a session. Ignores negative values. */
1809
1798
  addTokenUsage(sessionId: string, tokens: number): void;
1810
1799
  /**
@@ -1825,15 +1814,6 @@ declare class SessionManager {
1825
1814
  status?: string;
1826
1815
  limit?: number;
1827
1816
  }): UnifiedSession[];
1828
- /** Get overflow status for a session. Uses latest turn's input_tokens as context fullness signal. */
1829
- getOverflowStatus(sessionId: string): SessionOverflowStatus;
1830
- /** Pre-call check: auto-rollover if session context is over threshold. Call before every codex interaction. */
1831
- preCallOverflowCheck(sessionId: string, threshold?: number): {
1832
- rolled: boolean;
1833
- message?: string;
1834
- };
1835
- /** Roll over to a new codex thread (on context overflow). Returns new thread info. */
1836
- rolloverThread(sessionId: string): void;
1837
1817
  /** Record a GPT interaction event. Stores preview (500 chars) + optional full text. */
1838
1818
  recordEvent(params: {
1839
1819
  sessionId: string;
@@ -2679,6 +2659,6 @@ declare const DEFAULT_DLP_CONFIG: DlpConfig;
2679
2659
  */
2680
2660
  declare function sanitize(input: string, config?: Partial<DlpConfig>): DlpResult;
2681
2661
 
2682
- declare const VERSION = "0.2.13";
2662
+ declare const VERSION = "0.2.14";
2683
2663
 
2684
- export { type ArtifactRecord, ArtifactStore, type ArtifactType, type AssembledContext, type AttemptResult, BINARY_SNIFF_BYTES, type BridgeCapabilities, type BridgeOptions, type BridgeResumeOptions, type BudgetConfig, type BuildPhase, type BuildRun, BuildStore, type BuildSummary, type BuiltInRole, CLEANUP_TIMEOUT_SEC, CONTEXT_ACTIVE, CONTEXT_BUFFER, CONTEXT_RETRIEVED, CURRENT_VERSION, type CacheEntry, CacheStore, type CallModelOptions, CancellationError, CancellationToken, type ChatMessage, type CleanupConfidence, type CleanupFinding, type CleanupReport, type CleanupScope, type CleanupSource, CliAdapter, type CliAdapterConfig, type CliBridge, type CliCallOptions, type CliDetectionResult, ConfigError, type ContextBudget, ContextBuilder, type ContextBuilderOptions, type CostInput, type CostLogEntry, CostStore, type CostSummary, CostTracker, type CostUpdateEvent, DAYS_PER_YEAR, DEFAULT_CONFIG, DEFAULT_DLP_CONFIG, DEFAULT_MAX_TOKENS, DEFAULT_RULES, DEFAULT_TIMEOUT_SEC, DLP_MAX_CONTENT, DLP_MAX_PROCESSING_MS, DatabaseError, type DebateConfig, type DebateEngineState, type DebateInput, type DebateMessageRow, type DebateOptions, type DebatePattern, type DebateResponse, type DebateResult, DebateStore, type DebateTurnRow, type DebateTurnStatus, type DlpAuditEntry, type DlpConfig, type DlpMode, DlpReasonCode, type DlpRedaction, type DlpResult, type EngineEvent, type EnqueueOptions, ErrorCode, EventBus, type ExecutionMode, type FallbackConfig, HTTP_TOO_MANY_REQUESTS, type HandoffCommand, type HandoffEnvelopeOptions, type HostFindingInput, IMPLEMENTER_MAX_TOKENS, type JobLogRecord, type JobRecord, type JobStatus, JobStore, type JobType, type LogLevel, type Logger, type LoopConfig, LoopController, type LoopIterationEvent, type LoopResult, MCP_CONTENT_MAX_LENGTH, MCP_TASK_MAX_LENGTH, MCP_TIMEOUT_MAX, type MemoryCategory, type MemoryConfig, type MemoryInput, type MemoryRecord, MemoryStore, type MessageStatus, MessageStore, type MeteringSource, type ModelAdapter, type ModelCallResult, type ModelConfig, ModelError, type ModelPricing, type ModelProvider, ModelRegistry, Orchestrator, type OrchestratorOptions, type OutputConfig, type ParsedVerdict, type PlanInput, type PlanOptions, type PolicyContext, type PolicyDecision, type PolicyMode, type PolicyResult, type PolicyRule, type PresetName, type ProgressCallbacks, type ProjectConfig, type ProjectConfigInput, type PromptType, type PromptVariables, REVIEW_DIFF_MAX_CHARS, REVIEW_PRESETS, REVIEW_TEXT_MAX_CHARS, type ResolvedStep, type ResolvedWorkflow, type ResultStatus, type RetryConfig, type RetryOptions, type ReviewInput, type ReviewOptions, type ReviewPreset, type ReviewResult, type Role, type RoleConfig, RoleManager, type RunOptions, type Session, type SessionCompletedEvent, type SessionEvent, type SessionFailedEvent, SessionManager, type SessionOverflowStatus, type SessionResult, type SessionStartedEvent, type SessionStatus, SessionStore, type StepCompletedEvent, type StepDefinition, type StepFailedEvent, type StepResult, StepRunner, type StepStartedEvent, type StepType, TerminalReason, type TextDeltaEmitter, type TextDeltaEvent, type TextDoneEvent, type TokenUsage, type TranscriptEntry, type UnifiedSession, VERSION, type VerdictResult, type WorkflowDefinition, WorkflowEngine, WorkflowError, buildHandoffEnvelope, buildReconstructionPrompt, calculateCost, calculateDebateTokens, callModel, clearDetectionCache, computeThreeWayStats, computeTwoWayStats, costInputSchema, createIgnoreFilter, createLogger, debateInputSchema, debateOutputSchema, detectCli, estimateTokens, evaluatePolicy, generateId, generateSessionId, getModelPricing, getReviewPreset, getSchemaVersion, getTokenBudgetStatus, hashConfig, hashContent, hostFindingsSchema, isRateLimit, isRetryable, listPresetNames, listPresets, loadConfig, loadIgnorePatterns, loadPreset, memoryInputSchema, mergeThreeWay, mergeTwoWay, migrateConfig, openDatabase, parseDebateVerdict, parseVerdict, planInputSchema, preflightTokenCheck, projectConfigSchema, recalculateConfidenceStats, renderPrompt, reviewInputSchema, reviewOutputSchema, runAllScanners, runMigrations, sanitize, scanAntiPatterns, scanDeadCode, scanDuplicates, scanHardcoded, scanNearDuplicates, scanSecurity, scanUnusedDeps, scanUnusedExports, shouldIgnore, sleep, streamModel, validateConfig, withCanonicalRetry, withFallback, withRetry, writeConfig };
2664
+ export { type ArtifactRecord, ArtifactStore, type ArtifactType, type AssembledContext, type AttemptResult, BINARY_SNIFF_BYTES, type BridgeCapabilities, type BridgeOptions, type BridgeResumeOptions, type BudgetConfig, type BuildPhase, type BuildRun, BuildStore, type BuildSummary, type BuiltInRole, CLEANUP_TIMEOUT_SEC, CONTEXT_ACTIVE, CONTEXT_BUFFER, CONTEXT_RETRIEVED, CURRENT_VERSION, type CacheEntry, CacheStore, type CallModelOptions, CancellationError, CancellationToken, type ChatMessage, type CleanupConfidence, type CleanupFinding, type CleanupReport, type CleanupScope, type CleanupSource, CliAdapter, type CliAdapterConfig, type CliBridge, type CliCallOptions, type CliDetectionResult, ConfigError, type ContextBudget, ContextBuilder, type ContextBuilderOptions, type CostInput, type CostLogEntry, CostStore, type CostSummary, CostTracker, type CostUpdateEvent, DAYS_PER_YEAR, DEFAULT_CONFIG, DEFAULT_DLP_CONFIG, DEFAULT_MAX_TOKENS, DEFAULT_RULES, DEFAULT_TIMEOUT_SEC, DLP_MAX_CONTENT, DLP_MAX_PROCESSING_MS, DatabaseError, type DebateConfig, type DebateEngineState, type DebateInput, type DebateMessageRow, type DebateOptions, type DebatePattern, type DebateResponse, type DebateResult, DebateStore, type DebateTurnRow, type DebateTurnStatus, type DlpAuditEntry, type DlpConfig, type DlpMode, DlpReasonCode, type DlpRedaction, type DlpResult, type EngineEvent, type EnqueueOptions, ErrorCode, EventBus, type ExecutionMode, type FallbackConfig, HTTP_TOO_MANY_REQUESTS, type HandoffCommand, type HandoffEnvelopeOptions, type HostFindingInput, IMPLEMENTER_MAX_TOKENS, type JobLogRecord, type JobRecord, type JobStatus, JobStore, type JobType, type LogLevel, type Logger, type LoopConfig, LoopController, type LoopIterationEvent, type LoopResult, MCP_CONTENT_MAX_LENGTH, MCP_TASK_MAX_LENGTH, MCP_TIMEOUT_MAX, type MemoryCategory, type MemoryConfig, type MemoryInput, type MemoryRecord, MemoryStore, type MessageStatus, MessageStore, type MeteringSource, type ModelAdapter, type ModelCallResult, type ModelConfig, ModelError, type ModelPricing, type ModelProvider, ModelRegistry, Orchestrator, type OrchestratorOptions, type OutputConfig, type ParsedVerdict, type PlanInput, type PlanOptions, type PolicyContext, type PolicyDecision, type PolicyMode, type PolicyResult, type PolicyRule, type PresetName, type ProgressCallbacks, type ProjectConfig, type ProjectConfigInput, type PromptType, type PromptVariables, REVIEW_DIFF_MAX_CHARS, REVIEW_PRESETS, REVIEW_TEXT_MAX_CHARS, type ResolvedStep, type ResolvedWorkflow, type ResultStatus, type RetryConfig, type RetryOptions, type ReviewInput, type ReviewOptions, type ReviewPreset, type ReviewResult, type Role, type RoleConfig, RoleManager, type RunOptions, type Session, type SessionCompletedEvent, type SessionEvent, type SessionFailedEvent, SessionManager, type SessionResult, type SessionStartedEvent, type SessionStatus, SessionStore, type StepCompletedEvent, type StepDefinition, type StepFailedEvent, type StepResult, StepRunner, type StepStartedEvent, type StepType, TerminalReason, type TextDeltaEmitter, type TextDeltaEvent, type TextDoneEvent, type TokenUsage, type TranscriptEntry, type UnifiedSession, VERSION, type VerdictResult, type WorkflowDefinition, WorkflowEngine, WorkflowError, buildHandoffEnvelope, buildReconstructionPrompt, calculateCost, calculateDebateTokens, callModel, clearDetectionCache, computeThreeWayStats, computeTwoWayStats, costInputSchema, createIgnoreFilter, createLogger, debateInputSchema, debateOutputSchema, detectCli, estimateTokens, evaluatePolicy, generateId, generateSessionId, getModelPricing, getReviewPreset, getSchemaVersion, getTokenBudgetStatus, hashConfig, hashContent, hostFindingsSchema, isRateLimit, isRetryable, listPresetNames, listPresets, loadConfig, loadIgnorePatterns, loadPreset, memoryInputSchema, mergeThreeWay, mergeTwoWay, migrateConfig, openDatabase, parseDebateVerdict, parseVerdict, planInputSchema, preflightTokenCheck, projectConfigSchema, recalculateConfidenceStats, renderPrompt, reviewInputSchema, reviewOutputSchema, runAllScanners, runMigrations, sanitize, scanAntiPatterns, scanDeadCode, scanDuplicates, scanHardcoded, scanNearDuplicates, scanSecurity, scanUnusedDeps, scanUnusedExports, shouldIgnore, sleep, streamModel, validateConfig, withCanonicalRetry, withFallback, withRetry, writeConfig };
package/dist/index.js CHANGED
@@ -2295,7 +2295,7 @@ var SessionManager = class {
2295
2295
  const id = this.create(autoName);
2296
2296
  return this.get(id);
2297
2297
  }
2298
- /** Update the codex thread ID for a session (after first GPT call). */
2298
+ /** Update the codex thread ID for a session. Pass null to clear. */
2299
2299
  updateThreadId(sessionId, threadId) {
2300
2300
  this.db.prepare(
2301
2301
  "UPDATE codemoot_sessions SET codex_thread_id = ?, updated_at = ? WHERE id = ?"
@@ -2347,49 +2347,6 @@ var SessionManager = class {
2347
2347
  const rows = this.db.prepare(sql).all(...params);
2348
2348
  return rows.map((r) => this.toSession(r));
2349
2349
  }
2350
- /** Get overflow status for a session. Uses latest turn's input_tokens as context fullness signal. */
2351
- getOverflowStatus(sessionId) {
2352
- const session = this.get(sessionId);
2353
- if (!session) {
2354
- return { cumulativeTokens: 0, lastTurnInputTokens: 0, maxContext: 4e5, utilizationRatio: 0, shouldWarn: false, shouldReconstruct: false };
2355
- }
2356
- const maxCtx = session.maxContext > 0 && session.maxContext !== 128e3 ? session.maxContext : 4e5;
2357
- const latestEvents = this.getEvents(sessionId, 1);
2358
- let lastTurnInput = 0;
2359
- if (latestEvents.length > 0 && latestEvents[0].usageJson) {
2360
- try {
2361
- const usage = JSON.parse(latestEvents[0].usageJson);
2362
- const raw = usage.inputTokens ?? usage.input_tokens ?? 0;
2363
- lastTurnInput = typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? raw : 0;
2364
- } catch {
2365
- }
2366
- }
2367
- const ratio = lastTurnInput / maxCtx;
2368
- return {
2369
- cumulativeTokens: session.tokenUsage,
2370
- lastTurnInputTokens: lastTurnInput,
2371
- maxContext: maxCtx,
2372
- utilizationRatio: ratio,
2373
- shouldWarn: ratio > 0.75,
2374
- shouldReconstruct: ratio > 0.85
2375
- };
2376
- }
2377
- /** Pre-call check: auto-rollover if session context is over threshold. Call before every codex interaction. */
2378
- preCallOverflowCheck(sessionId, threshold = 0.85) {
2379
- const status = this.getOverflowStatus(sessionId);
2380
- if (status.utilizationRatio > threshold) {
2381
- this.rolloverThread(sessionId);
2382
- const pct = Math.round(status.utilizationRatio * 100);
2383
- return { rolled: true, message: `Session at ${pct}%. Rolling over to new thread.` };
2384
- }
2385
- return { rolled: false };
2386
- }
2387
- /** Roll over to a new codex thread (on context overflow). Returns new thread info. */
2388
- rolloverThread(sessionId) {
2389
- this.db.prepare(
2390
- "UPDATE codemoot_sessions SET codex_thread_id = NULL, updated_at = ? WHERE id = ?"
2391
- ).run(Date.now(), sessionId);
2392
- }
2393
2350
  // ── Session Events ──
2394
2351
  /** Record a GPT interaction event. Stores preview (500 chars) + optional full text. */
2395
2352
  recordEvent(params) {
@@ -6100,7 +6057,7 @@ var hostFindingSchema = z3.object({
6100
6057
  var hostFindingsSchema = z3.array(hostFindingSchema);
6101
6058
 
6102
6059
  // src/index.ts
6103
- var VERSION = "0.2.13";
6060
+ var VERSION = "0.2.14";
6104
6061
  export {
6105
6062
  ArtifactStore,
6106
6063
  BINARY_SNIFF_BYTES,