@wundam/orchex 1.0.0-rc.20 → 1.0.0-rc.22

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 CHANGED
@@ -12,8 +12,8 @@ Your AI assistant does tasks one at a time. Orchex makes it do 10 at once — sa
12
12
  - **Ownership Enforcement** — Each stream can only modify files in its `owns` array. No two agents touch the same file. Zero conflicts.
13
13
  - **`orchex run`** — Describe what you want, get parallel execution. Auto-generates plans, previews waves, executes with ownership enforcement.
14
14
  - **`orchex learn`** — The advanced path. Paste a markdown plan, get executable parallel streams with dependency inference and anti-pattern detection.
15
- - **Self-Healing** — Categorized error analysis with targeted fix streams. Not blind retry.
16
- - **Multi-LLM** — OpenAI, Gemini, Claude, DeepSeek, Ollama, AWS Bedrock. Route different orchestrations to different providers.
15
+ - **Self-Healing** — Categorized error analysis with targeted fix streams. Not blind retry. Model validation before execution prevents wasted API calls.
16
+ - **Multi-LLM** — OpenAI, Gemini, Claude, DeepSeek, Ollama, AWS Bedrock. Dynamic model registry auto-discovers available models. Key-aware routing prevents "model not found" errors.
17
17
  - **BYOK** — Bring your own API key from any supported provider. You control costs.
18
18
 
19
19
  ## Prerequisites
package/dist/index.js CHANGED
@@ -140,6 +140,14 @@ async function handleLoginCommand(args) {
140
140
  catch {
141
141
  // Non-fatal — entitlement sync is best-effort
142
142
  }
143
+ // Also cache model registry for offline use
144
+ try {
145
+ const { fetchAndCacheModels } = await import('./model-cache.js');
146
+ await fetchAndCacheModels(apiUrl);
147
+ }
148
+ catch {
149
+ // Non-fatal — model registry can be fetched on-demand later
150
+ }
143
151
  console.log('');
144
152
  return;
145
153
  }
@@ -537,7 +545,27 @@ async function handleRunCommand(args) {
537
545
  }
538
546
  const waveList = waves.map(w => ({ number: w.number, streams: w.streams.map(s => s.id) }));
539
547
  const allWarnings = [...result.warnings, ...diagnostics.warnings];
540
- const preview = formatPlanPreview(initStreams, waveList, allWarnings, seqDiag);
548
+ // Validate models for each stream and build model decisions map
549
+ const { resolveModel } = await import('./model-validator.js');
550
+ const { resolveApiUrl, DEFAULT_MODELS } = await import('./config.js');
551
+ const { estimatePlannedCost } = await import('./intelligence/index.js');
552
+ const modelApiUrl = config.mode === 'cloud' && config.apiKey ? await resolveApiUrl() : undefined;
553
+ const modelDecisions = {};
554
+ for (const [id, stream] of Object.entries(initStreams)) {
555
+ const suggestedProvider = stream.suggestedProvider ?? resolvedProvider;
556
+ const suggestedModel = DEFAULT_MODELS[suggestedProvider] ?? modelFlag;
557
+ const validation = await resolveModel(suggestedProvider, suggestedModel, modelApiUrl);
558
+ // Estimate cost using cost-tracker
559
+ const ownedLines = (stream.owns ?? []).length * 100; // rough estimate
560
+ const costEstimate = estimatePlannedCost(ownedLines * 4, validation.resolvedModel); // ~4 tokens/line
561
+ modelDecisions[id] = {
562
+ provider: suggestedProvider,
563
+ model: validation.resolvedModel,
564
+ estimatedCostUsd: costEstimate.finalCost,
565
+ fallback: validation.wasFallback ? `${validation.originalModel} → ${validation.resolvedModel}` : undefined,
566
+ };
567
+ }
568
+ const preview = formatPlanPreview(initStreams, waveList, allWarnings, seqDiag, modelDecisions);
541
569
  // Show preview
542
570
  console.log(formatPlanPreviewText(preview));
543
571
  if (dryRun) {
@@ -4,7 +4,7 @@ export { extractDeliverables, processDeliverables, formatDeliverablesReport } fr
4
4
  export type { Deliverable } from './deliverable-extractor.js';
5
5
  export { buildDependencyGraph, formatDependencyReport } from './dependency-inferrer.js';
6
6
  export { generateStreams, formatStreamsForReview, toInitFormat, extractPrerequisites } from './stream-generator.js';
7
- export { formatPlanPreview, formatPlanPreviewText } from './plan-preview.js';
7
+ export { formatPlanPreview, formatPlanPreviewText, type ModelDecision } from './plan-preview.js';
8
8
  export { detectSequentialEdits, autoFixSequentialEdits } from './sequential-diagnostics.js';
9
9
  export type { SequentialEditDiagnostic } from './sequential-diagnostics.js';
10
10
  export { createDiagnostics, detectOwnershipConflicts } from './diagnostics.js';
@@ -30,14 +30,14 @@ export { applyPartialApproval, rollbackStream } from './interactive-approval.js'
30
30
  export { generateFixStream } from './self-healer.js';
31
31
  export { cleanupOrphanFixStreams, getFixChainInfo, isFixStream, getOriginalStreamId, onStreamComplete } from './fix-stream-manager.js';
32
32
  export { routeStream, loadRoutingRules } from './smart-router.js';
33
- export type { RouteDecision } from './smart-router.js';
33
+ export type { RouteDecision, RouteOptions } from './smart-router.js';
34
34
  export { detectPatterns, formatPatterns, patternsToPromptHints, savePatterns, loadPatterns, adaptReport } from './pattern-detector.js';
35
35
  export type { DetectorInput } from './pattern-detector.js';
36
36
  export { pruneUnusedFiles, estimateTokens, generateCachingHints } from './context-optimizer.js';
37
37
  export { checkBudget, createBudgetConfig, ContextBudgetExceededError } from './budget-enforcer.js';
38
38
  export type { BudgetCheckResult } from './budget-enforcer.js';
39
39
  export { extractRelevantChunks } from './file-chunker.js';
40
- export { getModelCosts } from './cost-tracker.js';
40
+ export { getModelCosts, estimatePlannedCost } from './cost-tracker.js';
41
41
  export { extractImports, resolveImportPath } from './heuristics.js';
42
42
  export { findMatchingTemplate, applyTemplate, suggestSplit } from './slicing-templates.js';
43
43
  export { optimizeTopology } from './topology-optimizer.js';