reasonix 0.25.0 → 0.26.0
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/cli/index.js +2245 -1667
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +124 -9
- package/dist/index.js +1067 -490
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -218,6 +218,111 @@ declare function aggregateBranchUsage(samples: readonly BranchSample[]): {
|
|
|
218
218
|
promptCacheMissTokens: number;
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
+
/** Generic pause gate — bridges tool functions and the App's modals via Promises. */
|
|
222
|
+
type ConfirmationChoice = {
|
|
223
|
+
type: "deny";
|
|
224
|
+
denyContext?: string;
|
|
225
|
+
} | {
|
|
226
|
+
type: "run_once";
|
|
227
|
+
} | {
|
|
228
|
+
type: "always_allow";
|
|
229
|
+
prefix: string;
|
|
230
|
+
};
|
|
231
|
+
type PlanVerdict = {
|
|
232
|
+
type: "approve";
|
|
233
|
+
} | {
|
|
234
|
+
type: "refine";
|
|
235
|
+
} | {
|
|
236
|
+
type: "cancel";
|
|
237
|
+
};
|
|
238
|
+
type CheckpointVerdict = {
|
|
239
|
+
type: "continue";
|
|
240
|
+
} | {
|
|
241
|
+
type: "revise";
|
|
242
|
+
feedback?: string;
|
|
243
|
+
} | {
|
|
244
|
+
type: "stop";
|
|
245
|
+
};
|
|
246
|
+
type RevisionVerdict = {
|
|
247
|
+
type: "accepted";
|
|
248
|
+
} | {
|
|
249
|
+
type: "rejected";
|
|
250
|
+
} | {
|
|
251
|
+
type: "cancelled";
|
|
252
|
+
};
|
|
253
|
+
type ChoiceVerdict = {
|
|
254
|
+
type: "pick";
|
|
255
|
+
optionId: string;
|
|
256
|
+
} | {
|
|
257
|
+
type: "text";
|
|
258
|
+
text: string;
|
|
259
|
+
} | {
|
|
260
|
+
type: "cancel";
|
|
261
|
+
};
|
|
262
|
+
interface PauseResponseMap {
|
|
263
|
+
run_command: ConfirmationChoice;
|
|
264
|
+
run_background: ConfirmationChoice;
|
|
265
|
+
plan_proposed: PlanVerdict;
|
|
266
|
+
plan_checkpoint: CheckpointVerdict;
|
|
267
|
+
plan_revision: RevisionVerdict;
|
|
268
|
+
choice: ChoiceVerdict;
|
|
269
|
+
}
|
|
270
|
+
type PauseKind = keyof PauseResponseMap;
|
|
271
|
+
interface PausePayloadMap {
|
|
272
|
+
run_command: {
|
|
273
|
+
command: string;
|
|
274
|
+
};
|
|
275
|
+
run_background: {
|
|
276
|
+
command: string;
|
|
277
|
+
};
|
|
278
|
+
plan_proposed: {
|
|
279
|
+
plan: string;
|
|
280
|
+
steps?: unknown[];
|
|
281
|
+
summary?: string;
|
|
282
|
+
};
|
|
283
|
+
plan_checkpoint: {
|
|
284
|
+
stepId: string;
|
|
285
|
+
title?: string;
|
|
286
|
+
result: string;
|
|
287
|
+
notes?: string;
|
|
288
|
+
};
|
|
289
|
+
plan_revision: {
|
|
290
|
+
reason: string;
|
|
291
|
+
remainingSteps: unknown[];
|
|
292
|
+
summary?: string;
|
|
293
|
+
};
|
|
294
|
+
choice: {
|
|
295
|
+
question: string;
|
|
296
|
+
options: unknown[];
|
|
297
|
+
allowCustom: boolean;
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
type PauseRequest = {
|
|
301
|
+
id: number;
|
|
302
|
+
kind: PauseKind;
|
|
303
|
+
payload: unknown;
|
|
304
|
+
};
|
|
305
|
+
type GateListener = (request: PauseRequest) => void;
|
|
306
|
+
/** Named options for PauseGate.ask() — makes it obvious which field is kind vs payload. */
|
|
307
|
+
interface PauseAskOpts<K extends PauseKind = PauseKind> {
|
|
308
|
+
kind: K;
|
|
309
|
+
payload: PausePayloadMap[K];
|
|
310
|
+
}
|
|
311
|
+
declare class PauseGate {
|
|
312
|
+
private _nextId;
|
|
313
|
+
private _pending;
|
|
314
|
+
private _listeners;
|
|
315
|
+
/** Block until the user responds. Takes a named options object so the
|
|
316
|
+
* kind and payload fields don't get confused at the call site. */
|
|
317
|
+
ask<K extends PauseKind>(opts: PauseAskOpts<K>): Promise<PauseResponseMap[K]>;
|
|
318
|
+
/** Resolve a pending request. Called by the App's modal callback. */
|
|
319
|
+
resolve(id: number, data: unknown): void;
|
|
320
|
+
/** Subscribe to new pause requests. Returns an unsubscribe function. */
|
|
321
|
+
on(fn: GateListener): () => void;
|
|
322
|
+
/** Current pending request, if any (polling fallback). */
|
|
323
|
+
get current(): PauseRequest | null;
|
|
324
|
+
}
|
|
325
|
+
|
|
221
326
|
/** Shell-command hooks; project scope first, then global. Exit 0=pass, 2=block on Pre*, other=warn. */
|
|
222
327
|
type HookEvent = "PreToolUse" | "PostToolUse" | "UserPromptSubmit" | "Stop";
|
|
223
328
|
/** All four events as a const array — drives slash listing + validation. */
|
|
@@ -482,6 +587,8 @@ declare class SessionStats {
|
|
|
482
587
|
|
|
483
588
|
interface ToolCallContext {
|
|
484
589
|
signal?: AbortSignal;
|
|
590
|
+
/** Inject a mock PauseGate for tests. When absent, tools use the singleton. */
|
|
591
|
+
confirmationGate?: PauseGate;
|
|
485
592
|
}
|
|
486
593
|
interface ToolDefinition<A = any, R = any> {
|
|
487
594
|
name: string;
|
|
@@ -522,6 +629,8 @@ declare class ToolRegistry {
|
|
|
522
629
|
signal?: AbortSignal;
|
|
523
630
|
maxResultChars?: number;
|
|
524
631
|
maxResultTokens?: number;
|
|
632
|
+
/** Inject a mock PauseGate for tests. */
|
|
633
|
+
confirmationGate?: PauseGate;
|
|
525
634
|
}): Promise<string>;
|
|
526
635
|
}
|
|
527
636
|
|
|
@@ -587,6 +696,8 @@ interface CacheFirstLoopOptions {
|
|
|
587
696
|
hooks?: ResolvedHook[];
|
|
588
697
|
/** `cwd` reported to hooks; `reasonix code` sets this to the sandbox root, not shell home. */
|
|
589
698
|
hookCwd?: string;
|
|
699
|
+
/** PauseGate bridge — defaults to singleton, injectable for tests. */
|
|
700
|
+
confirmationGate?: PauseGate;
|
|
590
701
|
}
|
|
591
702
|
interface ReconfigurableOptions {
|
|
592
703
|
model?: string;
|
|
@@ -621,6 +732,8 @@ declare class CacheFirstLoop {
|
|
|
621
732
|
sessionName: string | null;
|
|
622
733
|
hooks: ResolvedHook[];
|
|
623
734
|
hookCwd: string;
|
|
735
|
+
/** PauseGate bridge — defaults to singleton, injectable for tests. */
|
|
736
|
+
readonly confirmationGate: PauseGate;
|
|
624
737
|
/** Number of messages that were pre-loaded from the session file. */
|
|
625
738
|
readonly resumedMessageCount: number;
|
|
626
739
|
private _turn;
|
|
@@ -632,16 +745,18 @@ declare class CacheFirstLoop {
|
|
|
632
745
|
private _turnFailureCount;
|
|
633
746
|
private _turnFailureTypes;
|
|
634
747
|
private _turnSelfCorrected;
|
|
748
|
+
private _foldedThisTurn;
|
|
749
|
+
private context;
|
|
635
750
|
constructor(opts: CacheFirstLoopOptions);
|
|
636
|
-
/**
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
}
|
|
751
|
+
/** Replace older turns with one summary message; keep tail within keepRecentTokens budget. */
|
|
752
|
+
compactHistory(opts?: {
|
|
753
|
+
keepRecentTokens?: number;
|
|
754
|
+
}): Promise<{
|
|
755
|
+
folded: boolean;
|
|
756
|
+
beforeMessages: number;
|
|
757
|
+
afterMessages: number;
|
|
758
|
+
summaryChars: number;
|
|
759
|
+
}>;
|
|
645
760
|
appendAndPersist(message: ChatMessage): void;
|
|
646
761
|
/** Swap the just-appended assistant entry — used by self-correction to restore the original tool_calls without dropping reasoning_content. */
|
|
647
762
|
private replaceTailAssistantMessage;
|