openplanter 0.1.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.
Files changed (126) hide show
  1. package/README.md +210 -0
  2. package/dist/builder.d.ts +11 -0
  3. package/dist/builder.d.ts.map +1 -0
  4. package/dist/builder.js +179 -0
  5. package/dist/builder.js.map +1 -0
  6. package/dist/cli.d.ts +9 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +548 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/config.d.ts +51 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/config.js +114 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/credentials.d.ts +52 -0
  15. package/dist/credentials.d.ts.map +1 -0
  16. package/dist/credentials.js +371 -0
  17. package/dist/credentials.js.map +1 -0
  18. package/dist/demo.d.ts +26 -0
  19. package/dist/demo.d.ts.map +1 -0
  20. package/dist/demo.js +95 -0
  21. package/dist/demo.js.map +1 -0
  22. package/dist/engine.d.ts +91 -0
  23. package/dist/engine.d.ts.map +1 -0
  24. package/dist/engine.js +1036 -0
  25. package/dist/engine.js.map +1 -0
  26. package/dist/index.d.ts +30 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +39 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/investigation-tools/aph-holdings.d.ts +61 -0
  31. package/dist/investigation-tools/aph-holdings.d.ts.map +1 -0
  32. package/dist/investigation-tools/aph-holdings.js +459 -0
  33. package/dist/investigation-tools/aph-holdings.js.map +1 -0
  34. package/dist/investigation-tools/asic-officer-lookup.d.ts +42 -0
  35. package/dist/investigation-tools/asic-officer-lookup.d.ts.map +1 -0
  36. package/dist/investigation-tools/asic-officer-lookup.js +197 -0
  37. package/dist/investigation-tools/asic-officer-lookup.js.map +1 -0
  38. package/dist/investigation-tools/asx-calendar-fetcher.d.ts +42 -0
  39. package/dist/investigation-tools/asx-calendar-fetcher.d.ts.map +1 -0
  40. package/dist/investigation-tools/asx-calendar-fetcher.js +271 -0
  41. package/dist/investigation-tools/asx-calendar-fetcher.js.map +1 -0
  42. package/dist/investigation-tools/asx-parser.d.ts +66 -0
  43. package/dist/investigation-tools/asx-parser.d.ts.map +1 -0
  44. package/dist/investigation-tools/asx-parser.js +314 -0
  45. package/dist/investigation-tools/asx-parser.js.map +1 -0
  46. package/dist/investigation-tools/bulk-asx-announcements.d.ts +53 -0
  47. package/dist/investigation-tools/bulk-asx-announcements.d.ts.map +1 -0
  48. package/dist/investigation-tools/bulk-asx-announcements.js +204 -0
  49. package/dist/investigation-tools/bulk-asx-announcements.js.map +1 -0
  50. package/dist/investigation-tools/entity-resolver.d.ts +77 -0
  51. package/dist/investigation-tools/entity-resolver.d.ts.map +1 -0
  52. package/dist/investigation-tools/entity-resolver.js +346 -0
  53. package/dist/investigation-tools/entity-resolver.js.map +1 -0
  54. package/dist/investigation-tools/hotcopper-scraper.d.ts +73 -0
  55. package/dist/investigation-tools/hotcopper-scraper.d.ts.map +1 -0
  56. package/dist/investigation-tools/hotcopper-scraper.js +318 -0
  57. package/dist/investigation-tools/hotcopper-scraper.js.map +1 -0
  58. package/dist/investigation-tools/index.d.ts +15 -0
  59. package/dist/investigation-tools/index.d.ts.map +1 -0
  60. package/dist/investigation-tools/index.js +15 -0
  61. package/dist/investigation-tools/index.js.map +1 -0
  62. package/dist/investigation-tools/insider-graph.d.ts +173 -0
  63. package/dist/investigation-tools/insider-graph.d.ts.map +1 -0
  64. package/dist/investigation-tools/insider-graph.js +732 -0
  65. package/dist/investigation-tools/insider-graph.js.map +1 -0
  66. package/dist/investigation-tools/insider-suspicion-scorer.d.ts +97 -0
  67. package/dist/investigation-tools/insider-suspicion-scorer.d.ts.map +1 -0
  68. package/dist/investigation-tools/insider-suspicion-scorer.js +327 -0
  69. package/dist/investigation-tools/insider-suspicion-scorer.js.map +1 -0
  70. package/dist/investigation-tools/multi-forum-scraper.d.ts +104 -0
  71. package/dist/investigation-tools/multi-forum-scraper.d.ts.map +1 -0
  72. package/dist/investigation-tools/multi-forum-scraper.js +415 -0
  73. package/dist/investigation-tools/multi-forum-scraper.js.map +1 -0
  74. package/dist/investigation-tools/price-fetcher.d.ts +81 -0
  75. package/dist/investigation-tools/price-fetcher.d.ts.map +1 -0
  76. package/dist/investigation-tools/price-fetcher.js +268 -0
  77. package/dist/investigation-tools/price-fetcher.js.map +1 -0
  78. package/dist/investigation-tools/shared.d.ts +39 -0
  79. package/dist/investigation-tools/shared.d.ts.map +1 -0
  80. package/dist/investigation-tools/shared.js +203 -0
  81. package/dist/investigation-tools/shared.js.map +1 -0
  82. package/dist/investigation-tools/timeline-linker.d.ts +90 -0
  83. package/dist/investigation-tools/timeline-linker.d.ts.map +1 -0
  84. package/dist/investigation-tools/timeline-linker.js +219 -0
  85. package/dist/investigation-tools/timeline-linker.js.map +1 -0
  86. package/dist/investigation-tools/volume-scanner.d.ts +70 -0
  87. package/dist/investigation-tools/volume-scanner.d.ts.map +1 -0
  88. package/dist/investigation-tools/volume-scanner.js +227 -0
  89. package/dist/investigation-tools/volume-scanner.js.map +1 -0
  90. package/dist/model.d.ts +136 -0
  91. package/dist/model.d.ts.map +1 -0
  92. package/dist/model.js +1071 -0
  93. package/dist/model.js.map +1 -0
  94. package/dist/patching.d.ts +45 -0
  95. package/dist/patching.d.ts.map +1 -0
  96. package/dist/patching.js +317 -0
  97. package/dist/patching.js.map +1 -0
  98. package/dist/prompts.d.ts +15 -0
  99. package/dist/prompts.d.ts.map +1 -0
  100. package/dist/prompts.js +351 -0
  101. package/dist/prompts.js.map +1 -0
  102. package/dist/replay-log.d.ts +54 -0
  103. package/dist/replay-log.d.ts.map +1 -0
  104. package/dist/replay-log.js +94 -0
  105. package/dist/replay-log.js.map +1 -0
  106. package/dist/runtime.d.ts +53 -0
  107. package/dist/runtime.d.ts.map +1 -0
  108. package/dist/runtime.js +259 -0
  109. package/dist/runtime.js.map +1 -0
  110. package/dist/settings.d.ts +39 -0
  111. package/dist/settings.d.ts.map +1 -0
  112. package/dist/settings.js +146 -0
  113. package/dist/settings.js.map +1 -0
  114. package/dist/tool-defs.d.ts +58 -0
  115. package/dist/tool-defs.d.ts.map +1 -0
  116. package/dist/tool-defs.js +1029 -0
  117. package/dist/tool-defs.js.map +1 -0
  118. package/dist/tools.d.ts +72 -0
  119. package/dist/tools.d.ts.map +1 -0
  120. package/dist/tools.js +1454 -0
  121. package/dist/tools.js.map +1 -0
  122. package/dist/tui.d.ts +49 -0
  123. package/dist/tui.d.ts.map +1 -0
  124. package/dist/tui.js +699 -0
  125. package/dist/tui.js.map +1 -0
  126. package/package.json +126 -0
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # OpenPlanter
2
+
3
+ A recursive-language-model investigation agent with CLI, TUI, and ASX investigation tools. Designed to be imported as a module into other Node.js/TypeScript projects or used standalone via the CLI.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install openplanter
9
+ ```
10
+
11
+ Requires Node.js >= 18.0.0.
12
+
13
+ ## Quick Start
14
+
15
+ ### As a CLI
16
+
17
+ ```bash
18
+ # Configure API keys (interactive prompt)
19
+ npx openplanter-agent --configure-keys
20
+
21
+ # Launch the TUI
22
+ npx openplanter-agent --workspace /path/to/project
23
+
24
+ # Run a single task headlessly
25
+ npx openplanter-agent --task "Analyse recent director trades for BHP" --workspace ./data
26
+ ```
27
+
28
+ ### As a Module
29
+
30
+ ```typescript
31
+ import { buildEngine, agentConfigFromEnv } from "openplanter";
32
+
33
+ const config = agentConfigFromEnv();
34
+ const engine = await buildEngine(config);
35
+ ```
36
+
37
+ Import specific submodules for lighter bundles:
38
+
39
+ ```typescript
40
+ import { RLMEngine } from "openplanter/engine";
41
+ import { Conversation, OpenAICompatibleModel } from "openplanter/model";
42
+ import { WorkspaceTools } from "openplanter/tools";
43
+ import { agentConfigFromEnv } from "openplanter/config";
44
+ ```
45
+
46
+ ### Investigation Tools
47
+
48
+ All ASX investigation tools are available as typed async functions:
49
+
50
+ ```typescript
51
+ import {
52
+ priceFetcher,
53
+ volumeScanner,
54
+ entityResolver,
55
+ insiderGraph,
56
+ insiderSuspicionScorer,
57
+ timelineLinker,
58
+ aphHoldings,
59
+ asicOfficerLookup,
60
+ asxCalendarFetcher,
61
+ asxParser,
62
+ bulkAsxAnnouncements,
63
+ hotcopperScraper,
64
+ multiForumScraper,
65
+ } from "openplanter/investigation-tools";
66
+
67
+ // Fetch price data from Yahoo Finance
68
+ const ohlcv = await priceFetcher.fetchOhlcv(["BHP", "RIO"], "3mo", "1d");
69
+
70
+ // Scan for volume/price anomalies
71
+ const anomalies = await volumeScanner.scanTickers(["BHP"], { lookbackDays: 60 });
72
+
73
+ // Resolve entities across datasets
74
+ const resolved = entityResolver.modeResolve(entities, 80);
75
+
76
+ // Build and analyse an insider trading graph
77
+ const graph = insiderGraph.buildGraph(graphData);
78
+ const path = insiderGraph.findShortestPath(graph, "person-1", "event-1");
79
+
80
+ // Score trades for suspicion
81
+ const scores = insiderSuspicionScorer.scoreTrades(trades, anomalyData, rumors, holdings);
82
+
83
+ // Correlate trades with announcements
84
+ const correlations = timelineLinker.correlate(trades, events);
85
+ ```
86
+
87
+ Or import individual tools directly:
88
+
89
+ ```typescript
90
+ import { fetchOhlcv, computeMetrics } from "openplanter/investigation-tools/price-fetcher";
91
+ import { scrapeHotcopper } from "openplanter/investigation-tools/hotcopper-scraper";
92
+ ```
93
+
94
+ ## Supported Providers
95
+
96
+ | Provider | Default Model | Env Var |
97
+ |----------|---------------|---------|
98
+ | OpenAI | `gpt-5.2` | `OPENAI_API_KEY` |
99
+ | Anthropic | `claude-opus-4-6` | `ANTHROPIC_API_KEY` |
100
+ | OpenRouter | `anthropic/claude-sonnet-4-5` | `OPENROUTER_API_KEY` |
101
+ | Cerebras | `qwen-3-235b-a22b-instruct-2507` | `CEREBRAS_API_KEY` |
102
+
103
+ Additional service keys: `EXA_API_KEY` (web search), `VOYAGE_API_KEY` (embeddings).
104
+
105
+ All keys can also be set with an `OPENPLANTER_` prefix, via `.env` files, or via CLI flags.
106
+
107
+ ## Agent Tools
108
+
109
+ The agent has access to 19 tools organized around its investigation workflow:
110
+
111
+ - **Workspace** -- `list_files`, `search_files`, `repo_map`, `read_file`, `write_file`, `edit_file`, `hashline_edit`, `apply_patch`
112
+ - **Shell** -- `run_shell`, `run_shell_bg`, `check_shell_bg`, `kill_shell_bg`
113
+ - **Web** -- `web_search` (Exa), `fetch_url`
114
+ - **Planning** -- `think`, `subtask`, `execute`, `list_artifacts`, `read_artifact`
115
+
116
+ In recursive mode (the default), the agent spawns sub-agents via `subtask` and `execute`.
117
+
118
+ ## CLI Reference
119
+
120
+ ```
121
+ openplanter-agent [options]
122
+ ```
123
+
124
+ | Flag | Description |
125
+ |------|-------------|
126
+ | `--workspace DIR` | Workspace root (default: `.`) |
127
+ | `--provider NAME` | `auto`, `openai`, `anthropic`, `openrouter`, `cerebras` |
128
+ | `--model NAME` | Model name or `newest` to auto-select |
129
+ | `--task OBJECTIVE` | Run a single task and exit (headless) |
130
+ | `--recursive` | Enable recursive sub-agent delegation |
131
+ | `--max-depth N` | Maximum recursion depth (default: 4) |
132
+ | `--max-steps N` | Maximum steps per call (default: 100) |
133
+ | `--no-tui` | Plain REPL (no colors or spinner) |
134
+ | `--headless` | Non-interactive mode (for CI) |
135
+ | `--resume` | Resume the latest session |
136
+ | `--configure-keys` | Interactive key configuration |
137
+ | `--list-models` | Fetch available models |
138
+ | `--show-settings` | Show workspace settings |
139
+
140
+ ## TUI Commands
141
+
142
+ | Command | Action |
143
+ |---------|--------|
144
+ | `/model [NAME]` | Show or switch model |
145
+ | `/reasoning LEVEL` | Change reasoning effort |
146
+ | `/status` | Show session status and token usage |
147
+ | `/clear` | Clear the screen |
148
+ | `/quit` | Exit |
149
+
150
+ ## Configuration
151
+
152
+ Keys are resolved in priority order:
153
+
154
+ 1. CLI flags
155
+ 2. Environment variables (`OPENAI_API_KEY` or `OPENPLANTER_OPENAI_API_KEY`)
156
+ 3. `.env` file in the workspace
157
+ 4. Workspace credential store (`.openplanter/credentials.json`)
158
+ 5. User credential store (`~/.openplanter/credentials.json`)
159
+
160
+ ## Project Structure
161
+
162
+ ```
163
+ src/
164
+ index.ts Library entry point
165
+ cli.ts CLI entry point and REPL
166
+ engine.ts Recursive language model engine
167
+ runtime.ts Session persistence and lifecycle
168
+ model.ts Provider-agnostic LLM abstraction
169
+ builder.ts Engine/model factory
170
+ tools.ts Workspace tool implementations
171
+ tool-defs.ts Tool JSON schemas
172
+ prompts.ts System prompt construction
173
+ config.ts Configuration dataclass
174
+ credentials.ts Credential management
175
+ tui.ts Rich terminal UI
176
+ demo.ts Demo mode (output censoring)
177
+ patching.ts File patching utilities
178
+ settings.ts Persistent settings
179
+ replay-log.ts Replay logging
180
+ investigation-tools/
181
+ index.ts Investigation tools barrel export
182
+ shared.ts Shared utilities (HTTP, dates, sentiment, normalization)
183
+ aph-holdings.ts APH politician holdings scraper
184
+ asic-officer-lookup.ts ASIC officer/director lookup
185
+ asx-calendar-fetcher.ts ASX 4C calendar fetcher
186
+ asx-parser.ts ASX announcement parser (3Y, 4C, halts)
187
+ bulk-asx-announcements.ts Bulk ASX announcement fetcher
188
+ entity-resolver.ts Fuzzy entity matching and resolution
189
+ hotcopper-scraper.ts HotCopper forum scraper
190
+ insider-graph.ts Entity-event graph analysis
191
+ insider-suspicion-scorer.ts Composite suspicion scorer
192
+ multi-forum-scraper.ts Multi-forum sentiment aggregator
193
+ price-fetcher.ts Yahoo Finance OHLCV data and metrics
194
+ timeline-linker.ts Trade-announcement timeline correlation
195
+ volume-scanner.ts Volume/price anomaly scanner
196
+ ```
197
+
198
+ ## Development
199
+
200
+ ```bash
201
+ npm install
202
+ npm run build # Compile TypeScript
203
+ npm run lint # Type-check without emitting
204
+ npm run dev # Run CLI via tsx (development)
205
+ npm test # Run tests
206
+ ```
207
+
208
+ ## License
209
+
210
+ MIT
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Engine construction and model listing helpers.
3
+ *
4
+ * Migrated from agent/builder.py to TypeScript.
5
+ */
6
+ import type { AgentConfig } from "./config.js";
7
+ import { RLMEngine } from "./engine.js";
8
+ export declare function inferProviderForModel(model: string): string | null;
9
+ export declare function _fetchModelsForProvider(cfg: AgentConfig, provider: string): Promise<Record<string, unknown>[]>;
10
+ export declare function buildEngine(cfg: AgentConfig): RLMEngine;
11
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAsB3D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOlE;AAqBD,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAsCpC;AA2DD,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,CA4DvD"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Engine construction and model listing helpers.
3
+ *
4
+ * Migrated from agent/builder.py to TypeScript.
5
+ */
6
+ import { RLMEngine } from "./engine.js";
7
+ import { AnthropicModel, EchoFallbackModel, ModelError, OpenAICompatibleModel, listOpenaiModels, listAnthropicModels, listOpenrouterModels, } from "./model.js";
8
+ import { get_tool_definitions } from "./tool-defs.js";
9
+ import { WorkspaceTools } from "./tools.js";
10
+ // ---------------------------------------------------------------------------
11
+ // Provider inference
12
+ // ---------------------------------------------------------------------------
13
+ const _ANTHROPIC_RE = /^claude/i;
14
+ const _OPENAI_RE = /^(gpt|o[1-4]-|o[1-4]$|chatgpt|dall-e|tts-|whisper)/i;
15
+ const _CEREBRAS_RE = /^(llama.*cerebras|qwen-3|gpt-oss|zai-glm)/i;
16
+ const _GROK_RE = /^grok/i;
17
+ export function inferProviderForModel(model) {
18
+ if (model.includes("/"))
19
+ return "openrouter";
20
+ if (_ANTHROPIC_RE.test(model))
21
+ return "anthropic";
22
+ if (_GROK_RE.test(model))
23
+ return "grok";
24
+ if (_CEREBRAS_RE.test(model))
25
+ return "cerebras";
26
+ if (_OPENAI_RE.test(model))
27
+ return "openai";
28
+ return null;
29
+ }
30
+ // ---------------------------------------------------------------------------
31
+ // Model validation
32
+ // ---------------------------------------------------------------------------
33
+ function _validateModelProvider(modelName, provider) {
34
+ if (provider === "openrouter")
35
+ return;
36
+ const inferred = inferProviderForModel(modelName);
37
+ if (inferred && inferred !== provider) {
38
+ throw new ModelError(`Model '${modelName}' appears to be for provider '${inferred}', ` +
39
+ `but configured provider is '${provider}'.`);
40
+ }
41
+ }
42
+ // ---------------------------------------------------------------------------
43
+ // Model listing
44
+ // ---------------------------------------------------------------------------
45
+ export async function _fetchModelsForProvider(cfg, provider) {
46
+ switch (provider) {
47
+ case "openai": {
48
+ if (!cfg.openaiApiKey) {
49
+ throw new ModelError("OpenAI API key not configured.");
50
+ }
51
+ return listOpenaiModels(cfg.openaiApiKey, cfg.openaiBaseUrl);
52
+ }
53
+ case "anthropic": {
54
+ if (!cfg.anthropicApiKey) {
55
+ throw new ModelError("Anthropic API key not configured.");
56
+ }
57
+ return listAnthropicModels(cfg.anthropicApiKey, cfg.anthropicBaseUrl);
58
+ }
59
+ case "openrouter": {
60
+ if (!cfg.openrouterApiKey) {
61
+ throw new ModelError("OpenRouter API key not configured.");
62
+ }
63
+ return listOpenrouterModels(cfg.openrouterApiKey, cfg.openrouterBaseUrl);
64
+ }
65
+ case "cerebras": {
66
+ if (!cfg.cerebrasApiKey) {
67
+ throw new ModelError("Cerebras API key not configured.");
68
+ }
69
+ return listOpenaiModels(cfg.cerebrasApiKey, cfg.cerebrasBaseUrl);
70
+ }
71
+ case "grok": {
72
+ if (!cfg.grokApiKey) {
73
+ throw new ModelError("Grok API key not configured.");
74
+ }
75
+ return listOpenaiModels(cfg.grokApiKey, cfg.grokBaseUrl);
76
+ }
77
+ default:
78
+ throw new ModelError(`Unknown provider: ${provider}`);
79
+ }
80
+ }
81
+ // ---------------------------------------------------------------------------
82
+ // Build model
83
+ // ---------------------------------------------------------------------------
84
+ function _buildModel(cfg, toolDefs) {
85
+ _validateModelProvider(cfg.model, cfg.provider);
86
+ if (cfg.provider === "anthropic") {
87
+ return new AnthropicModel({
88
+ model: cfg.model,
89
+ apiKey: cfg.anthropicApiKey ?? "",
90
+ baseUrl: cfg.anthropicBaseUrl,
91
+ reasoningEffort: cfg.reasoningEffort,
92
+ toolDefs: toolDefs,
93
+ });
94
+ }
95
+ // OpenAI-compatible: openai, openrouter, cerebras, grok
96
+ const keyMap = {
97
+ openai: cfg.openaiApiKey,
98
+ openrouter: cfg.openrouterApiKey,
99
+ cerebras: cfg.cerebrasApiKey,
100
+ grok: cfg.grokApiKey,
101
+ };
102
+ const baseUrlMap = {
103
+ openai: cfg.openaiBaseUrl,
104
+ openrouter: cfg.openrouterBaseUrl,
105
+ cerebras: cfg.cerebrasBaseUrl,
106
+ grok: cfg.grokBaseUrl,
107
+ };
108
+ const apiKey = keyMap[cfg.provider] ?? cfg.openaiApiKey ?? "";
109
+ const baseUrl = baseUrlMap[cfg.provider] ?? cfg.openaiBaseUrl;
110
+ const extraHeaders = {};
111
+ if (cfg.provider === "openrouter") {
112
+ extraHeaders["HTTP-Referer"] = "https://github.com/openplanter";
113
+ extraHeaders["X-Title"] = "OpenPlanter";
114
+ }
115
+ return new OpenAICompatibleModel({
116
+ model: cfg.model,
117
+ apiKey,
118
+ baseUrl,
119
+ reasoningEffort: cfg.reasoningEffort,
120
+ extraHeaders,
121
+ toolDefs: toolDefs,
122
+ });
123
+ }
124
+ // ---------------------------------------------------------------------------
125
+ // buildEngine
126
+ // ---------------------------------------------------------------------------
127
+ export function buildEngine(cfg) {
128
+ const hasKey = cfg.openaiApiKey ||
129
+ cfg.anthropicApiKey ||
130
+ cfg.openrouterApiKey ||
131
+ cfg.cerebrasApiKey ||
132
+ cfg.grokApiKey;
133
+ if (!hasKey) {
134
+ const model = new EchoFallbackModel();
135
+ const tools = new WorkspaceTools({
136
+ root: cfg.workspace,
137
+ shell: cfg.shell,
138
+ commandTimeoutSec: cfg.commandTimeoutSec,
139
+ maxShellOutputChars: cfg.maxShellOutputChars,
140
+ maxFileChars: cfg.maxFileChars,
141
+ maxFilesListed: cfg.maxFilesListed,
142
+ maxSearchHits: cfg.maxSearchHits,
143
+ exaApiKey: cfg.exaApiKey,
144
+ exaBaseUrl: cfg.exaBaseUrl,
145
+ });
146
+ return new RLMEngine({ model, tools, config: cfg });
147
+ }
148
+ const toolDefs = get_tool_definitions({
149
+ includeSubtask: cfg.recursive,
150
+ includeAcceptanceCriteria: cfg.acceptanceCriteria,
151
+ });
152
+ const model = _buildModel(cfg, toolDefs);
153
+ const tools = new WorkspaceTools({
154
+ root: cfg.workspace,
155
+ shell: cfg.shell,
156
+ commandTimeoutSec: cfg.commandTimeoutSec,
157
+ maxShellOutputChars: cfg.maxShellOutputChars,
158
+ maxFileChars: cfg.maxFileChars,
159
+ maxFilesListed: cfg.maxFilesListed,
160
+ maxSearchHits: cfg.maxSearchHits,
161
+ exaApiKey: cfg.exaApiKey,
162
+ exaBaseUrl: cfg.exaBaseUrl,
163
+ });
164
+ const modelFactory = (modelName, reasoningEffort) => {
165
+ const overrideCfg = {
166
+ ...cfg,
167
+ model: modelName,
168
+ reasoningEffort,
169
+ };
170
+ return _buildModel(overrideCfg, toolDefs);
171
+ };
172
+ return new RLMEngine({
173
+ model,
174
+ tools,
175
+ config: cfg,
176
+ modelFactory,
177
+ });
178
+ }
179
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAqB,MAAM,aA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M,EAAE,GAAG,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,QAAQ,GAAG,oBAAoB,CAAC;QACpC,cAAc,EAAE,GAAG,CAAC,SAAS;QAC7B,yBAAyB,EAAE,GAAG,CAAC,kBAAkB;KAClD,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC;QAC/B,IAAI,EAAE,GAAG,CAAC,SAAS;QACnB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,mBAAmB,EAAE,GAAG,CAAC,mBAAmB;QAC5C,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,UAAU,EAAE,GAAG,CAAC,UAAU;KAC3B,CAAC,CAAC;IAEH,MAAM,YAAY,GAAiB,CACjC,SAAiB,EACjB,eAA8B,EAC9B,EAAE;QACF,MAAM,WAAW,GAAgB;YAC/B,GAAG,GAAG;YACN,KAAK,EAAE,SAAS;YAChB,eAAe;SAChB,CAAC;QACF,OAAO,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC,CAAC;IAEF,OAAO,IAAI,SAAS,CAAC;QACnB,KAAK;QACL,KAAK;QACL,MAAM,EAAE,GAAG;QACX,YAAY;KACb,CAAC,CAAC;AACL,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry point – migrated from agent/__main__.py.
4
+ *
5
+ * Parses command-line arguments, loads credentials/settings, builds the
6
+ * engine, and launches the appropriate REPL or headless task mode.
7
+ */
8
+ export declare function main(): Promise<void>;
9
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AA2ZH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAyM1C"}