reasonix 0.0.4 → 0.0.5
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/README.md +133 -58
- package/dist/cli/index.js +716 -54
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +96 -6
- package/dist/index.js +460 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-Y7L6L5QS.js +0 -262
- package/dist/chunk-Y7L6L5QS.js.map +0 -1
- package/dist/cli/chunk-T2ODXAJP.js +0 -263
- package/dist/cli/chunk-T2ODXAJP.js.map +0 -1
- package/dist/cli/client-RIVGDOJP.js +0 -10
- package/dist/cli/client-RIVGDOJP.js.map +0 -1
- package/dist/client-KEA2D52Q.js +0 -9
- package/dist/client-KEA2D52Q.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -172,6 +172,58 @@ declare function emptyPlanState(): TypedPlanState;
|
|
|
172
172
|
declare function isPlanStateEmpty(s: TypedPlanState | null | undefined): boolean;
|
|
173
173
|
declare function harvest(reasoningContent: string | null | undefined, client?: DeepSeekClient, options?: HarvestOptions): Promise<TypedPlanState>;
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Self-consistency branching.
|
|
177
|
+
*
|
|
178
|
+
* When enabled, the loop fans out into N parallel samples per turn (varied
|
|
179
|
+
* temperatures), runs Pillar 2 harvest on each, and selects the sample with
|
|
180
|
+
* the fewest flagged uncertainties (ties broken by answer length — a crude
|
|
181
|
+
* Occam prior).
|
|
182
|
+
*
|
|
183
|
+
* The unique opportunity here: because DeepSeek is ~20× cheaper than Claude,
|
|
184
|
+
* running N=3–5 samples per turn is still cheaper than a single Claude call,
|
|
185
|
+
* while the majority-confidence selection tends to dominate single-sample
|
|
186
|
+
* answers on fuzzy multi-step reasoning tasks.
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
interface BranchSample {
|
|
190
|
+
index: number;
|
|
191
|
+
temperature: number;
|
|
192
|
+
response: ChatResponse;
|
|
193
|
+
planState: TypedPlanState;
|
|
194
|
+
}
|
|
195
|
+
type BranchSelector = (samples: BranchSample[]) => BranchSample;
|
|
196
|
+
interface BranchOptions {
|
|
197
|
+
/** Number of parallel samples. 1 disables branching. Default 1. */
|
|
198
|
+
budget?: number;
|
|
199
|
+
/** Temperatures for each branch. Default spreads across [0, 1]. */
|
|
200
|
+
temperatures?: readonly number[];
|
|
201
|
+
/** Harvest options; the selector needs harvest to score samples. */
|
|
202
|
+
harvestOptions?: HarvestOptions;
|
|
203
|
+
/** Custom selector. Default: min uncertainties, tie-break shortest answer. */
|
|
204
|
+
selector?: BranchSelector;
|
|
205
|
+
/**
|
|
206
|
+
* Fires as each sample finishes (main call + harvest both complete).
|
|
207
|
+
* Useful for progress UI. Not awaited; exceptions are swallowed.
|
|
208
|
+
*/
|
|
209
|
+
onSampleDone?: (sample: BranchSample) => void;
|
|
210
|
+
}
|
|
211
|
+
interface BranchResult {
|
|
212
|
+
chosen: BranchSample;
|
|
213
|
+
samples: BranchSample[];
|
|
214
|
+
}
|
|
215
|
+
/** Default: fewest uncertainties wins, ties broken by shorter answer content. */
|
|
216
|
+
declare const defaultSelector: BranchSelector;
|
|
217
|
+
declare function runBranches(client: DeepSeekClient, request: ChatRequestOptions, opts?: BranchOptions): Promise<BranchResult>;
|
|
218
|
+
/** Sum usage across branch samples for telemetry purposes. */
|
|
219
|
+
declare function aggregateBranchUsage(samples: readonly BranchSample[]): {
|
|
220
|
+
promptTokens: number;
|
|
221
|
+
completionTokens: number;
|
|
222
|
+
totalTokens: number;
|
|
223
|
+
promptCacheHitTokens: number;
|
|
224
|
+
promptCacheMissTokens: number;
|
|
225
|
+
};
|
|
226
|
+
|
|
175
227
|
interface ImmutablePrefixOptions {
|
|
176
228
|
system: string;
|
|
177
229
|
toolSpecs?: readonly ToolSpec[];
|
|
@@ -364,7 +416,20 @@ declare class ToolRegistry {
|
|
|
364
416
|
dispatch(name: string, argumentsRaw: string | Record<string, unknown>): Promise<string>;
|
|
365
417
|
}
|
|
366
418
|
|
|
367
|
-
type EventRole = "assistant_delta" | "assistant_final" | "tool" | "done" | "error";
|
|
419
|
+
type EventRole = "assistant_delta" | "assistant_final" | "tool" | "done" | "error" | "branch_start" | "branch_progress" | "branch_done";
|
|
420
|
+
interface BranchSummary {
|
|
421
|
+
budget: number;
|
|
422
|
+
chosenIndex: number;
|
|
423
|
+
uncertainties: number[];
|
|
424
|
+
temperatures: number[];
|
|
425
|
+
}
|
|
426
|
+
interface BranchProgress {
|
|
427
|
+
completed: number;
|
|
428
|
+
total: number;
|
|
429
|
+
latestIndex: number;
|
|
430
|
+
latestTemperature: number;
|
|
431
|
+
latestUncertainties: number;
|
|
432
|
+
}
|
|
368
433
|
interface LoopEvent {
|
|
369
434
|
turn: number;
|
|
370
435
|
role: EventRole;
|
|
@@ -374,6 +439,8 @@ interface LoopEvent {
|
|
|
374
439
|
stats?: TurnStats;
|
|
375
440
|
planState?: TypedPlanState;
|
|
376
441
|
repair?: RepairReport;
|
|
442
|
+
branch?: BranchSummary;
|
|
443
|
+
branchProgress?: BranchProgress;
|
|
377
444
|
error?: string;
|
|
378
445
|
}
|
|
379
446
|
interface CacheFirstLoopOptions {
|
|
@@ -389,6 +456,13 @@ interface CacheFirstLoopOptions {
|
|
|
389
456
|
* cheap but non-zero V3 call per turn).
|
|
390
457
|
*/
|
|
391
458
|
harvest?: boolean | HarvestOptions;
|
|
459
|
+
/**
|
|
460
|
+
* Self-consistency branching. Pass a number for just a budget (e.g. 3) or
|
|
461
|
+
* a full `BranchOptions` object. Disables streaming for the branched turn
|
|
462
|
+
* because all samples must complete before selection. Auto-enables harvest
|
|
463
|
+
* since the default selector scores samples by plan-state uncertainty.
|
|
464
|
+
*/
|
|
465
|
+
branch?: number | BranchOptions;
|
|
392
466
|
}
|
|
393
467
|
/**
|
|
394
468
|
* Pillar 1 — Cache-First Loop.
|
|
@@ -399,21 +473,37 @@ interface CacheFirstLoopOptions {
|
|
|
399
473
|
*
|
|
400
474
|
* Yields a stream of events so a TUI can render progressively.
|
|
401
475
|
*/
|
|
476
|
+
interface ReconfigurableOptions {
|
|
477
|
+
model?: string;
|
|
478
|
+
harvest?: boolean | HarvestOptions;
|
|
479
|
+
branch?: number | BranchOptions;
|
|
480
|
+
stream?: boolean;
|
|
481
|
+
}
|
|
402
482
|
declare class CacheFirstLoop {
|
|
403
483
|
readonly client: DeepSeekClient;
|
|
404
484
|
readonly prefix: ImmutablePrefix;
|
|
405
485
|
readonly tools: ToolRegistry;
|
|
406
|
-
readonly model: string;
|
|
407
486
|
readonly maxToolIters: number;
|
|
408
|
-
readonly stream: boolean;
|
|
409
|
-
readonly harvestEnabled: boolean;
|
|
410
|
-
readonly harvestOptions: HarvestOptions;
|
|
411
487
|
readonly log: AppendOnlyLog;
|
|
412
488
|
readonly scratch: VolatileScratch;
|
|
413
489
|
readonly stats: SessionStats;
|
|
414
490
|
readonly repair: ToolCallRepair;
|
|
491
|
+
model: string;
|
|
492
|
+
stream: boolean;
|
|
493
|
+
harvestEnabled: boolean;
|
|
494
|
+
harvestOptions: HarvestOptions;
|
|
495
|
+
branchEnabled: boolean;
|
|
496
|
+
branchOptions: BranchOptions;
|
|
415
497
|
private _turn;
|
|
498
|
+
private _streamPreference;
|
|
416
499
|
constructor(opts: CacheFirstLoopOptions);
|
|
500
|
+
/**
|
|
501
|
+
* Reconfigure model/harvest/branch/stream mid-session. The loop's log,
|
|
502
|
+
* scratch, and stats are preserved — only the per-turn behavior changes.
|
|
503
|
+
* Used by the TUI's slash commands and by library callers who want to
|
|
504
|
+
* flip a knob between turns.
|
|
505
|
+
*/
|
|
506
|
+
configure(opts: ReconfigurableOptions): void;
|
|
417
507
|
private buildMessages;
|
|
418
508
|
step(userInput: string): AsyncGenerator<LoopEvent>;
|
|
419
509
|
run(userInput: string, onEvent?: (ev: LoopEvent) => void): Promise<string>;
|
|
@@ -458,4 +548,4 @@ declare function redactKey(key: string): string;
|
|
|
458
548
|
|
|
459
549
|
declare const VERSION = "0.0.1";
|
|
460
550
|
|
|
461
|
-
export { AppendOnlyLog, CacheFirstLoop, type CacheFirstLoopOptions, type ChatMessage, type ChatResponse, DeepSeekClient, type DeepSeekClientOptions, type EventRole, type FlattenDecision, type HarvestOptions, ImmutablePrefix, type ImmutablePrefixOptions, type JSONSchema, type LoopEvent, type ReasonixConfig, type RepairReport, type RetryInfo, type RetryOptions, type Role, type ScavengeOptions, type ScavengeResult, SessionStats, type SessionSummary, StormBreaker, type StreamChunk, type ToolCall, ToolCallRepair, type ToolCallRepairOptions, type ToolDefinition, type ToolFunctionSpec, ToolRegistry, type ToolSpec, type TruncationRepairResult, type TurnStats, type TypedPlanState, Usage, VERSION, VolatileScratch, analyzeSchema, claudeEquivalentCost, costUsd, defaultConfigPath, emptyPlanState, fetchWithRetry, flattenSchema, harvest, isPlanStateEmpty, isPlausibleKey, loadApiKey, loadDotenv, nestArguments, readConfig, redactKey, repairTruncatedJson, saveApiKey, scavengeToolCalls, writeConfig };
|
|
551
|
+
export { AppendOnlyLog, type BranchOptions, type BranchProgress, type BranchResult, type BranchSample, type BranchSelector, type BranchSummary, CacheFirstLoop, type CacheFirstLoopOptions, type ChatMessage, type ChatResponse, DeepSeekClient, type DeepSeekClientOptions, type EventRole, type FlattenDecision, type HarvestOptions, ImmutablePrefix, type ImmutablePrefixOptions, type JSONSchema, type LoopEvent, type ReasonixConfig, type ReconfigurableOptions, type RepairReport, type RetryInfo, type RetryOptions, type Role, type ScavengeOptions, type ScavengeResult, SessionStats, type SessionSummary, StormBreaker, type StreamChunk, type ToolCall, ToolCallRepair, type ToolCallRepairOptions, type ToolDefinition, type ToolFunctionSpec, ToolRegistry, type ToolSpec, type TruncationRepairResult, type TurnStats, type TypedPlanState, Usage, VERSION, VolatileScratch, aggregateBranchUsage, analyzeSchema, claudeEquivalentCost, costUsd, defaultConfigPath, defaultSelector, emptyPlanState, fetchWithRetry, flattenSchema, harvest, isPlanStateEmpty, isPlausibleKey, loadApiKey, loadDotenv, nestArguments, readConfig, redactKey, repairTruncatedJson, runBranches, saveApiKey, scavengeToolCalls, writeConfig };
|