reasonix 0.4.14 → 0.4.16
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 +66 -0
- package/dist/cli/index.js +1098 -300
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +197 -2
- package/dist/index.js +435 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -762,6 +762,184 @@ interface FilesystemToolsOptions {
|
|
|
762
762
|
}
|
|
763
763
|
declare function registerFilesystemTools(registry: ToolRegistry, opts: FilesystemToolsOptions): ToolRegistry;
|
|
764
764
|
|
|
765
|
+
/**
|
|
766
|
+
* Native shell tool — lets the model run commands inside the sandbox
|
|
767
|
+
* root so it can actually verify its own work (run tests, check git
|
|
768
|
+
* status, inspect a lockfile, etc.). Without this the coding-mode
|
|
769
|
+
* loop is "write code, hope it works, ask the user to run it" —
|
|
770
|
+
* defeats the purpose.
|
|
771
|
+
*
|
|
772
|
+
* Safety model:
|
|
773
|
+
* - Commands run with `cwd` pinned to the registered root. No
|
|
774
|
+
* path traversal via the command itself is enforced (users can
|
|
775
|
+
* `cat ../outside.txt`); the trust boundary is the directory
|
|
776
|
+
* you opened Reasonix from.
|
|
777
|
+
* - Commands are matched against a read-only / testing allowlist.
|
|
778
|
+
* Allowlisted commands execute immediately and return stdout +
|
|
779
|
+
* stderr merged. Everything else throws with a clear message —
|
|
780
|
+
* the UI translates that into an `/apply`-style confirm gate so
|
|
781
|
+
* the user sees the exact command before it runs.
|
|
782
|
+
* - Default timeout: 60s. Output cap: matches tool-result budget.
|
|
783
|
+
* - Every command that DOES run is spawned with `shell: false` and
|
|
784
|
+
* a tokenized argv — no string-to-shell interpolation, so the
|
|
785
|
+
* model can't accidentally construct a chained `rm` via quoting.
|
|
786
|
+
*
|
|
787
|
+
* This is intentionally narrower than what Claude Code / Aider ship:
|
|
788
|
+
* we gate more commands behind confirmation by default. Users who
|
|
789
|
+
* trust the model can widen the allowlist by instantiating their
|
|
790
|
+
* own tool registry.
|
|
791
|
+
*/
|
|
792
|
+
|
|
793
|
+
interface ShellToolsOptions {
|
|
794
|
+
/** Directory to run commands in. Must be an absolute path. */
|
|
795
|
+
rootDir: string;
|
|
796
|
+
/** Seconds before an individual command is killed. Default: 60. */
|
|
797
|
+
timeoutSec?: number;
|
|
798
|
+
/**
|
|
799
|
+
* Per-command stdout+stderr cap in characters. Default: 32_000 to
|
|
800
|
+
* match the tool-result budget.
|
|
801
|
+
*/
|
|
802
|
+
maxOutputChars?: number;
|
|
803
|
+
/**
|
|
804
|
+
* Extra command-name prefixes the user explicitly trusts. Added on
|
|
805
|
+
* top of the built-in allowlist. Examples: `["my-ci-script", "lint"]`.
|
|
806
|
+
*/
|
|
807
|
+
extraAllowed?: string[];
|
|
808
|
+
/**
|
|
809
|
+
* When true, skip the allowlist entirely and auto-run every command.
|
|
810
|
+
* Off by default — this is an escape hatch for non-interactive use
|
|
811
|
+
* (CI, benchmarks) where a human can't be in the loop to confirm.
|
|
812
|
+
*/
|
|
813
|
+
allowAll?: boolean;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Tokenize a shell-ish command string into argv. Handles single/double
|
|
817
|
+
* quoting; rejects unclosed quotes. Does NOT expand env vars, globs,
|
|
818
|
+
* backticks, or `$(…)` — the goal is to prevent the model from
|
|
819
|
+
* accidentally (or not) sneaking arbitrary shells past the allowlist
|
|
820
|
+
* via concatenation. Exported for testing.
|
|
821
|
+
*/
|
|
822
|
+
declare function tokenizeCommand(cmd: string): string[];
|
|
823
|
+
/**
|
|
824
|
+
* Return true when `cmd` matches an allowlisted prefix. Exported for
|
|
825
|
+
* testing. Match is on the space-normalized leading tokens so
|
|
826
|
+
* `git status -s ` and `git status` both match `git status`.
|
|
827
|
+
*/
|
|
828
|
+
declare function isAllowed(cmd: string, extra?: readonly string[]): boolean;
|
|
829
|
+
interface RunCommandResult {
|
|
830
|
+
exitCode: number | null;
|
|
831
|
+
/** Combined stdout+stderr, truncated to `maxOutputChars` with a marker. */
|
|
832
|
+
output: string;
|
|
833
|
+
/** True when the process was killed for exceeding `timeoutSec`. */
|
|
834
|
+
timedOut: boolean;
|
|
835
|
+
}
|
|
836
|
+
declare function runCommand(cmd: string, opts: {
|
|
837
|
+
cwd: string;
|
|
838
|
+
timeoutSec?: number;
|
|
839
|
+
maxOutputChars?: number;
|
|
840
|
+
signal?: AbortSignal;
|
|
841
|
+
}): Promise<RunCommandResult>;
|
|
842
|
+
/** Error thrown by `run_command` when the command isn't allowlisted. */
|
|
843
|
+
declare class NeedsConfirmationError extends Error {
|
|
844
|
+
readonly command: string;
|
|
845
|
+
constructor(command: string);
|
|
846
|
+
}
|
|
847
|
+
declare function registerShellTools(registry: ToolRegistry, opts: ShellToolsOptions): ToolRegistry;
|
|
848
|
+
declare function formatCommandResult(cmd: string, r: RunCommandResult): string;
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Built-in web search + fetch tools.
|
|
852
|
+
*
|
|
853
|
+
* - `web_search(query, topK?)` — Mojeek's public search page. No API
|
|
854
|
+
* key, no signup. We originally shipped this backed by DuckDuckGo's
|
|
855
|
+
* HTML endpoint, but DDG started serving anti-bot interstitials
|
|
856
|
+
* (HTTP 202 with a challenge page) for every unauthenticated POST.
|
|
857
|
+
* Mojeek runs its own independent index, is bot-friendly, and
|
|
858
|
+
* returns parseable HTML.
|
|
859
|
+
* - `web_fetch(url)` — HTTP GET + naïve HTML-to-text extraction.
|
|
860
|
+
*
|
|
861
|
+
* Both are registered by default on `reasonix chat` / `reasonix code`;
|
|
862
|
+
* set `search: false` in config (or `REASONIX_SEARCH=off`) to turn
|
|
863
|
+
* them off. The model decides when to call them based on the query —
|
|
864
|
+
* no slash command required.
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
interface SearchResult {
|
|
868
|
+
title: string;
|
|
869
|
+
url: string;
|
|
870
|
+
snippet: string;
|
|
871
|
+
}
|
|
872
|
+
interface PageContent {
|
|
873
|
+
url: string;
|
|
874
|
+
title?: string;
|
|
875
|
+
text: string;
|
|
876
|
+
/** True when the extracted text was clipped to fit the cap. */
|
|
877
|
+
truncated: boolean;
|
|
878
|
+
}
|
|
879
|
+
interface WebFetchOptions {
|
|
880
|
+
/** Max bytes of extracted text. Defaults to 32_000 to match tool-result cap. */
|
|
881
|
+
maxChars?: number;
|
|
882
|
+
/** Timeout in ms. Defaults to 15_000. */
|
|
883
|
+
timeoutMs?: number;
|
|
884
|
+
signal?: AbortSignal;
|
|
885
|
+
}
|
|
886
|
+
interface WebSearchOptions {
|
|
887
|
+
topK?: number;
|
|
888
|
+
signal?: AbortSignal;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Search the public web via Mojeek. Returns up to `topK` ranked
|
|
892
|
+
* results with title, url, snippet.
|
|
893
|
+
*
|
|
894
|
+
* Mojeek is an independent index (not a Google/Bing front-end) which
|
|
895
|
+
* means coverage on niche or very recent topics can be thinner, but
|
|
896
|
+
* it's reliable from scripts and doesn't gate on cookies or sessions.
|
|
897
|
+
* If the response has 0 results we distinguish "truly empty" from
|
|
898
|
+
* "layout changed or blocked" so the caller isn't left guessing.
|
|
899
|
+
*/
|
|
900
|
+
declare function webSearch(query: string, opts?: WebSearchOptions): Promise<SearchResult[]>;
|
|
901
|
+
/**
|
|
902
|
+
* Extract results from a Mojeek search page.
|
|
903
|
+
*
|
|
904
|
+
* Mojeek's stable shape (as of April 2026):
|
|
905
|
+
* <a … class="ob" href="URL"> … breadcrumb … </a>
|
|
906
|
+
* <h2><a class="title" href="URL">Title</a></h2>
|
|
907
|
+
* <p class="s">snippet text …</p>
|
|
908
|
+
*
|
|
909
|
+
* We do two tolerant passes — title anchors, then snippet paragraphs —
|
|
910
|
+
* and pair them positionally. Attribute order inside a tag varies
|
|
911
|
+
* between versions, so each pass captures the whole element and we
|
|
912
|
+
* re-extract href / inner text with a second regex. Exported for
|
|
913
|
+
* unit testing against a fixture.
|
|
914
|
+
*/
|
|
915
|
+
declare function parseMojeekResults(html: string): SearchResult[];
|
|
916
|
+
/**
|
|
917
|
+
* Download a URL, strip HTML down to readable text, return it. Times
|
|
918
|
+
* out at 15s, caps extracted text at 32k chars to fit the tool-result
|
|
919
|
+
* budget.
|
|
920
|
+
*/
|
|
921
|
+
declare function webFetch(url: string, opts?: WebFetchOptions): Promise<PageContent>;
|
|
922
|
+
/**
|
|
923
|
+
* Strip HTML to readable text. Removes scripts/styles/nav/footer/aside
|
|
924
|
+
* blocks first, then tags, then collapses whitespace. Not a Readability
|
|
925
|
+
* clone — purpose-built to keep the extracted text small enough for the
|
|
926
|
+
* tool-result budget while preserving paragraph breaks.
|
|
927
|
+
*/
|
|
928
|
+
declare function htmlToText(html: string): string;
|
|
929
|
+
interface WebToolsOptions {
|
|
930
|
+
/** Default top-K for `web_search` when the model doesn't specify. */
|
|
931
|
+
defaultTopK?: number;
|
|
932
|
+
/** Byte cap for `web_fetch` extracted text. */
|
|
933
|
+
maxFetchChars?: number;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Register `web_search` + `web_fetch` on a ToolRegistry. The model
|
|
937
|
+
* invokes them automatically when a question needs current info —
|
|
938
|
+
* no slash command from the user is required.
|
|
939
|
+
*/
|
|
940
|
+
declare function registerWebTools(registry: ToolRegistry, opts?: WebToolsOptions): ToolRegistry;
|
|
941
|
+
declare function formatSearchResults(query: string, results: SearchResult[]): string;
|
|
942
|
+
|
|
765
943
|
/**
|
|
766
944
|
* Session persistence.
|
|
767
945
|
*
|
|
@@ -1745,6 +1923,23 @@ interface ReasonixConfig {
|
|
|
1745
1923
|
session?: string | null;
|
|
1746
1924
|
/** Marks that `reasonix setup` has completed at least once. */
|
|
1747
1925
|
setupCompleted?: boolean;
|
|
1926
|
+
/**
|
|
1927
|
+
* Whether `web_search` + `web_fetch` tools are registered. Default:
|
|
1928
|
+
* enabled (no key required — backed by DuckDuckGo's public HTML
|
|
1929
|
+
* endpoint). Set to `false` to keep the session offline.
|
|
1930
|
+
*/
|
|
1931
|
+
search?: boolean;
|
|
1932
|
+
/**
|
|
1933
|
+
* Per-project state keyed by absolute directory path. Written by the
|
|
1934
|
+
* "always allow" choice on a shell confirmation prompt; merged into
|
|
1935
|
+
* `registerShellTools({ extraAllowed })` when `reasonix code` runs
|
|
1936
|
+
* against that directory again.
|
|
1937
|
+
*/
|
|
1938
|
+
projects?: {
|
|
1939
|
+
[absoluteRootDir: string]: {
|
|
1940
|
+
shellAllowed?: string[];
|
|
1941
|
+
};
|
|
1942
|
+
};
|
|
1748
1943
|
}
|
|
1749
1944
|
declare function defaultConfigPath(): string;
|
|
1750
1945
|
declare function readConfig(path?: string): ReasonixConfig;
|
|
@@ -1758,6 +1953,6 @@ declare function redactKey(key: string): string;
|
|
|
1758
1953
|
|
|
1759
1954
|
/** Reasonix — DeepSeek-native agent framework. Library entry point. */
|
|
1760
1955
|
|
|
1761
|
-
declare const VERSION = "0.4.
|
|
1956
|
+
declare const VERSION = "0.4.16";
|
|
1762
1957
|
|
|
1763
|
-
export { AppendOnlyLog, type ApplyResult, type ApplyStatus, type BranchOptions, type BranchProgress, type BranchResult, type BranchSample, type BranchSelector, type BranchSummary, type BridgeOptions, type BridgeResult, CODE_SYSTEM_PROMPT, CacheFirstLoop, type CacheFirstLoopOptions, type CallToolResult, type ChatMessage, type ChatResponse, DEFAULT_MAX_RESULT_CHARS, DeepSeekClient, type DeepSeekClientOptions, type RenderOptions as DiffRenderOptions, type DiffReport, type DiffSide, type EditBlock, type EditSnapshot, type EventRole, type FilesystemToolsOptions, type FlattenDecision, type FlattenOptions, type GetPromptResult, type HarvestOptions, ImmutablePrefix, type ImmutablePrefixOptions, type InitializeResult, type InspectionReport, type JSONSchema, type JsonRpcMessage, type JsonRpcRequest, type JsonRpcResponse, type ListPromptsResult, type ListResourcesResult, type ListToolsResult, type LoopEvent, MCP_PROTOCOL_VERSION, McpClient, type McpClientOptions, type McpContentBlock, type McpProgressHandler, type McpProgressInfo, type McpPrompt, type McpPromptArgument, type McpPromptMessage, type McpPromptResourceBlock, type McpResource, type McpResourceContents, type McpResourceContentsBlob, type McpResourceContentsText, type McpSpec, type McpTool, type McpToolSchema, type McpTransport, type ProgressNotificationParams, type ReadResourceResult, type ReadTranscriptResult, type ReasonixConfig, type ReconfigurableOptions, type RepairReport, type ReplayStats, type RetryInfo, type RetryOptions, type Role, type ScavengeOptions, type ScavengeResult, type SectionResult, type SessionInfo, SessionStats, type SessionSummary, type SseMcpSpec, SseTransport, type SseTransportOptions, type StdioMcpSpec, StdioTransport, type StdioTransportOptions, StormBreaker, type StreamChunk, type ToolCall, type ToolCallContext, ToolCallRepair, type ToolCallRepairOptions, type ToolDefinition, type ToolFunctionSpec, ToolRegistry, type ToolSpec, type TranscriptMeta, type TranscriptRecord, type TruncationRepairResult, type TurnPair, type TurnStats, type TypedPlanState, Usage, VERSION, VolatileScratch, aggregateBranchUsage, analyzeSchema, appendSessionMessage, applyEditBlock, applyEditBlocks, bridgeMcpTools, claudeEquivalentCost, codeSystemPrompt, computeReplayStats, costUsd, defaultConfigPath, defaultSelector, deleteSession, diffTranscripts, emptyPlanState, fetchWithRetry, flattenMcpResult, flattenSchema, formatLoopError, harvest, healLoadedMessages, inputCostUsd, inspectMcpServer, isJsonRpcError, isPlanStateEmpty, isPlausibleKey, listSessions, loadApiKey, loadDotenv, loadSessionMessages, nestArguments, openTranscriptFile, outputCostUsd, parseEditBlocks, parseMcpSpec, parseTranscript, readConfig, readTranscript, recordFromLoopEvent, redactKey, registerFilesystemTools, renderMarkdown as renderDiffMarkdown, renderSummaryTable as renderDiffSummary, repairTruncatedJson, replayFromFile, restoreSnapshots, runBranches, sanitizeName as sanitizeSessionName, saveApiKey, scavengeToolCalls, sessionPath, sessionsDir, similarity, snapshotBeforeEdits, stripHallucinatedToolMarkup, truncateForModel, writeConfig, writeMeta, writeRecord };
|
|
1958
|
+
export { AppendOnlyLog, type ApplyResult, type ApplyStatus, type BranchOptions, type BranchProgress, type BranchResult, type BranchSample, type BranchSelector, type BranchSummary, type BridgeOptions, type BridgeResult, CODE_SYSTEM_PROMPT, CacheFirstLoop, type CacheFirstLoopOptions, type CallToolResult, type ChatMessage, type ChatResponse, DEFAULT_MAX_RESULT_CHARS, DeepSeekClient, type DeepSeekClientOptions, type RenderOptions as DiffRenderOptions, type DiffReport, type DiffSide, type EditBlock, type EditSnapshot, type EventRole, type FilesystemToolsOptions, type FlattenDecision, type FlattenOptions, type GetPromptResult, type HarvestOptions, ImmutablePrefix, type ImmutablePrefixOptions, type InitializeResult, type InspectionReport, type JSONSchema, type JsonRpcMessage, type JsonRpcRequest, type JsonRpcResponse, type ListPromptsResult, type ListResourcesResult, type ListToolsResult, type LoopEvent, MCP_PROTOCOL_VERSION, McpClient, type McpClientOptions, type McpContentBlock, type McpProgressHandler, type McpProgressInfo, type McpPrompt, type McpPromptArgument, type McpPromptMessage, type McpPromptResourceBlock, type McpResource, type McpResourceContents, type McpResourceContentsBlob, type McpResourceContentsText, type McpSpec, type McpTool, type McpToolSchema, type McpTransport, NeedsConfirmationError, type PageContent, type ProgressNotificationParams, type ReadResourceResult, type ReadTranscriptResult, type ReasonixConfig, type ReconfigurableOptions, type RepairReport, type ReplayStats, type RetryInfo, type RetryOptions, type Role, type RunCommandResult, type ScavengeOptions, type ScavengeResult, type SearchResult, type SectionResult, type SessionInfo, SessionStats, type SessionSummary, type ShellToolsOptions, type SseMcpSpec, SseTransport, type SseTransportOptions, type StdioMcpSpec, StdioTransport, type StdioTransportOptions, StormBreaker, type StreamChunk, type ToolCall, type ToolCallContext, ToolCallRepair, type ToolCallRepairOptions, type ToolDefinition, type ToolFunctionSpec, ToolRegistry, type ToolSpec, type TranscriptMeta, type TranscriptRecord, type TruncationRepairResult, type TurnPair, type TurnStats, type TypedPlanState, Usage, VERSION, VolatileScratch, type WebFetchOptions, type WebSearchOptions, type WebToolsOptions, aggregateBranchUsage, analyzeSchema, appendSessionMessage, applyEditBlock, applyEditBlocks, bridgeMcpTools, claudeEquivalentCost, codeSystemPrompt, computeReplayStats, costUsd, defaultConfigPath, defaultSelector, deleteSession, diffTranscripts, emptyPlanState, fetchWithRetry, flattenMcpResult, flattenSchema, formatCommandResult, formatLoopError, formatSearchResults, harvest, healLoadedMessages, htmlToText, inputCostUsd, inspectMcpServer, isAllowed, isJsonRpcError, isPlanStateEmpty, isPlausibleKey, listSessions, loadApiKey, loadDotenv, loadSessionMessages, nestArguments, openTranscriptFile, outputCostUsd, parseEditBlocks, parseMcpSpec, parseMojeekResults, parseTranscript, readConfig, readTranscript, recordFromLoopEvent, redactKey, registerFilesystemTools, registerShellTools, registerWebTools, renderMarkdown as renderDiffMarkdown, renderSummaryTable as renderDiffSummary, repairTruncatedJson, replayFromFile, restoreSnapshots, runBranches, runCommand, sanitizeName as sanitizeSessionName, saveApiKey, scavengeToolCalls, sessionPath, sessionsDir, similarity, snapshotBeforeEdits, stripHallucinatedToolMarkup, tokenizeCommand, truncateForModel, webFetch, webSearch, writeConfig, writeMeta, writeRecord };
|