hankweave 0.5.7 → 0.6.2
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 +12 -11
- package/dist/base-process-manager.d.ts +30 -0
- package/dist/budget.d.ts +315 -0
- package/dist/checkpoint-git.d.ts +98 -0
- package/dist/claude-agent-sdk-manager.d.ts +144 -0
- package/dist/claude-log-parser.d.ts +63 -0
- package/dist/claude-runtime-extractor.d.ts +73 -0
- package/dist/codex-runtime-extractor.d.ts +107 -0
- package/dist/codon-runner.d.ts +278 -0
- package/dist/config-validation/model-validator.d.ts +16 -0
- package/dist/config-validation/sentinel.schema.d.ts +6967 -0
- package/dist/config.d.ts +40815 -0
- package/dist/cost-tracker.d.ts +72 -0
- package/dist/execution-planner.d.ts +62 -0
- package/dist/execution-thread.d.ts +71 -0
- package/dist/exports/schemas.d.ts +9 -0
- package/dist/exports/schemas.js +1019 -0
- package/dist/exports/types.d.ts +15 -0
- package/dist/exports/types.js +60 -0
- package/dist/file-resolver.d.ts +33 -0
- package/dist/index.js +380 -293
- package/dist/index.js.map +33 -29
- package/dist/llm/llm-provider-registry.d.ts +207 -0
- package/dist/llm/models-dev-schema.d.ts +679 -0
- package/dist/llm/provider-config.d.ts +30 -0
- package/dist/prompt-builder.d.ts +75 -0
- package/dist/prompt-frontmatter.d.ts +61 -0
- package/dist/replay-process-manager.d.ts +82 -0
- package/dist/runtime-extractor-base.d.ts +120 -0
- package/dist/schemas/event-schemas.d.ts +8389 -0
- package/dist/schemas/websocket-log-schemas.d.ts +4502 -0
- package/dist/shim-process-manager.d.ts +98 -0
- package/dist/shim-runtime-extractor.d.ts +51 -0
- package/dist/shims/codex/README.md +129 -0
- package/dist/shims/codex/THIRDPARTY.md +18 -0
- package/dist/shims/codex/VERSION +1 -0
- package/dist/shims/codex/common/package.json +24 -0
- package/dist/shims/codex/index.js +1154 -970
- package/dist/shims/codex/package.json +46 -0
- package/dist/shims/codex/tsup.config.ts +16 -0
- package/dist/shims/gemini/README.md +59 -0
- package/dist/shims/gemini/THIRDPARTY.md +32 -0
- package/dist/shims/gemini/VERSION +1 -0
- package/dist/shims/gemini/common/package.json +24 -0
- package/dist/shims/gemini/index.js +1359 -30
- package/dist/shims/gemini/package.json +37 -0
- package/dist/shims/opencode/README.md +82 -0
- package/dist/shims/opencode/THIRDPARTY.md +32 -0
- package/dist/shims/opencode/VERSION +1 -0
- package/dist/shims/opencode/common/package.json +24 -0
- package/dist/shims/opencode/index.js +1476 -0
- package/dist/shims/opencode/package.json +38 -0
- package/dist/shims/pi/README.md +87 -0
- package/dist/shims/pi/THIRDPARTY.md +24 -0
- package/dist/shims/pi/VERSION +1 -0
- package/dist/shims/pi/common/package.json +24 -0
- package/dist/shims/pi/index.js +249832 -0
- package/dist/shims/pi/package.json +53 -0
- package/dist/state-manager.d.ts +161 -0
- package/dist/state-transition-guards.d.ts +37 -0
- package/dist/telemetry/telemetry-types.d.ts +206 -0
- package/dist/typed-event-emitter.d.ts +57 -0
- package/dist/types/branded-types.d.ts +15 -0
- package/dist/types/budget-types.d.ts +82 -0
- package/dist/types/claude-session-schema.d.ts +2430 -0
- package/dist/types/error-types.d.ts +44 -0
- package/dist/types/input-ai-types.d.ts +1070 -0
- package/dist/types/llm-call-types.d.ts +3829 -0
- package/dist/types/sentinel-types.d.ts +66 -0
- package/dist/types/state-types.d.ts +1099 -0
- package/dist/types/tool-types.d.ts +86 -0
- package/dist/types/types.d.ts +367 -0
- package/dist/types/websocket-log-types.d.ts +7 -0
- package/dist/utils.d.ts +452 -0
- package/package.json +15 -2
- package/schemas/hank.schema.json +158 -3
- package/schemas/hankweave.schema.json +17 -1
- package/shims/codex/index.js +0 -1583
- package/shims/gemini/index.js +0 -31
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import type { LanguageModel } from "ai";
|
|
2
|
+
import type { Logger } from "../utils.js";
|
|
3
|
+
import { type ModelInfo } from "./models-dev-schema.js";
|
|
4
|
+
/**
|
|
5
|
+
* Discriminated union for provider status
|
|
6
|
+
*/
|
|
7
|
+
export type ProviderStatus = {
|
|
8
|
+
status: "not-configured";
|
|
9
|
+
id: string;
|
|
10
|
+
error: string;
|
|
11
|
+
} | {
|
|
12
|
+
status: "available";
|
|
13
|
+
id: string;
|
|
14
|
+
healthy: boolean;
|
|
15
|
+
lastChecked?: Date;
|
|
16
|
+
error?: string;
|
|
17
|
+
} | {
|
|
18
|
+
status: "failed";
|
|
19
|
+
id: string;
|
|
20
|
+
error: string;
|
|
21
|
+
lastChecked: Date;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Result types for better error handling
|
|
25
|
+
*/
|
|
26
|
+
export type ModelResult = {
|
|
27
|
+
success: true;
|
|
28
|
+
model: LanguageModel;
|
|
29
|
+
} | {
|
|
30
|
+
success: false;
|
|
31
|
+
reason: "model-not-found" | "provider-unavailable" | "provider-unhealthy" | "model-blocked";
|
|
32
|
+
};
|
|
33
|
+
export type ModelInfoResult = {
|
|
34
|
+
success: true;
|
|
35
|
+
info: ModelInfo;
|
|
36
|
+
} | {
|
|
37
|
+
success: false;
|
|
38
|
+
reason: "model-not-found" | "model-blocked";
|
|
39
|
+
};
|
|
40
|
+
export type ResolveModelResult = {
|
|
41
|
+
success: true;
|
|
42
|
+
modelInfo: ModelInfo;
|
|
43
|
+
matchType: "exact" | "exact-with-inferred-provider" | "fuzzy";
|
|
44
|
+
} | {
|
|
45
|
+
success: false;
|
|
46
|
+
reason: "model-not-found" | "model-blocked";
|
|
47
|
+
};
|
|
48
|
+
export interface BlockList {
|
|
49
|
+
providers?: string[];
|
|
50
|
+
models?: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface LlmProviderRegistryConfig {
|
|
53
|
+
logger?: Logger;
|
|
54
|
+
healthCheckTimeout?: number;
|
|
55
|
+
performHealthCheckOnInit?: boolean;
|
|
56
|
+
blockList?: BlockList;
|
|
57
|
+
}
|
|
58
|
+
export declare class LlmProviderRegistry {
|
|
59
|
+
private static instance;
|
|
60
|
+
/**
|
|
61
|
+
* Common shortcuts for model names that map to search patterns.
|
|
62
|
+
* These are expanded before model resolution to improve matching.
|
|
63
|
+
*/
|
|
64
|
+
private static readonly MODEL_SHORTCUTS;
|
|
65
|
+
private providers;
|
|
66
|
+
private models;
|
|
67
|
+
private uniqueModels;
|
|
68
|
+
private providerStatus;
|
|
69
|
+
private logger?;
|
|
70
|
+
private healthCheckTimeout;
|
|
71
|
+
private blockList;
|
|
72
|
+
constructor(config?: LlmProviderRegistryConfig);
|
|
73
|
+
/**
|
|
74
|
+
* Get the singleton instance of LlmProviderRegistry.
|
|
75
|
+
* Creates a new instance with the provided config if one doesn't exist.
|
|
76
|
+
*
|
|
77
|
+
* @param config - Configuration for the registry (only used on first call)
|
|
78
|
+
* @returns The singleton instance
|
|
79
|
+
*/
|
|
80
|
+
static getInstance(config?: LlmProviderRegistryConfig): LlmProviderRegistry;
|
|
81
|
+
/**
|
|
82
|
+
* Reset the singleton instance (primarily for testing).
|
|
83
|
+
*/
|
|
84
|
+
static resetInstance(): void;
|
|
85
|
+
private loadModelsData;
|
|
86
|
+
/**
|
|
87
|
+
* Find the cheapest model for a provider.
|
|
88
|
+
* Used for health checks and credit validation where we want the
|
|
89
|
+
* lowest-cost model that still works as a chat model.
|
|
90
|
+
*
|
|
91
|
+
* Filters to:
|
|
92
|
+
* - Chat models only (not embeddings)
|
|
93
|
+
* - Models that support both text input and text output
|
|
94
|
+
*
|
|
95
|
+
* Prefers models updated in the last 6 months (more likely to still be
|
|
96
|
+
* active on the provider's API). Falls back to 1 year if nothing recent
|
|
97
|
+
* enough is found, then drops the date filter entirely as a last resort.
|
|
98
|
+
*/
|
|
99
|
+
findCheapestModel(providerId: string): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Get the best model for a health check.
|
|
102
|
+
* Tries provider-configured preferred models first (stable, non-preview IDs),
|
|
103
|
+
* then falls back to findCheapestModel.
|
|
104
|
+
*/
|
|
105
|
+
getHealthCheckModel(providerId: string): string | undefined;
|
|
106
|
+
private initializeProviders;
|
|
107
|
+
/**
|
|
108
|
+
* Check if a model is blocked by the blocklist.
|
|
109
|
+
* Checks both model-level and provider-level blocking (case-insensitive).
|
|
110
|
+
*
|
|
111
|
+
* @param modelInfo - The model information to check
|
|
112
|
+
* @returns true if the model or its provider is blocked
|
|
113
|
+
*/
|
|
114
|
+
private isModelBlocked;
|
|
115
|
+
/**
|
|
116
|
+
* Calculate Levenshtein distance between two strings
|
|
117
|
+
* Returns a similarity score from 0 to 1 (1 = identical)
|
|
118
|
+
*/
|
|
119
|
+
private calculateStringSimilarity;
|
|
120
|
+
/**
|
|
121
|
+
* Get preferred provider for a model based on naming patterns
|
|
122
|
+
* Uses fuzzy matching to handle typos
|
|
123
|
+
*/
|
|
124
|
+
private getPreferredProvider;
|
|
125
|
+
/**
|
|
126
|
+
* Find models matching the query using fuzzy matching
|
|
127
|
+
* Returns the most recent model above the similarity threshold
|
|
128
|
+
*
|
|
129
|
+
* @internal Match object: { model: ModelInfo, score: number, hasExactWordMatch: boolean }
|
|
130
|
+
*/
|
|
131
|
+
private fuzzyMatchModels;
|
|
132
|
+
performHealthChecks(): Promise<Map<string, ProviderStatus>>;
|
|
133
|
+
/**
|
|
134
|
+
* Get a provider and model for a specific model name with parameter validation.
|
|
135
|
+
* Returns a result object with success/failure information.
|
|
136
|
+
*/
|
|
137
|
+
getProviderForModel(modelName: string, llmParams?: {
|
|
138
|
+
temperature?: number;
|
|
139
|
+
maxOutputTokens?: number;
|
|
140
|
+
}): ModelResult;
|
|
141
|
+
/**
|
|
142
|
+
* Get cost information for a model.
|
|
143
|
+
*/
|
|
144
|
+
getModelInfo(modelName: string): ModelInfoResult;
|
|
145
|
+
/**
|
|
146
|
+
* Resolve a model name to model information with support for:
|
|
147
|
+
* - Exact matching with explicit provider
|
|
148
|
+
* - Exact matching with provider inference
|
|
149
|
+
* - Fuzzy matching with provider preferences
|
|
150
|
+
*
|
|
151
|
+
* @param input.providerId - Optional provider ID (e.g., "anthropic", "google", "openai")
|
|
152
|
+
* @param input.model - Model name (exact or fuzzy, e.g., "claude-3-5-sonnet" or "claude-sonnet")
|
|
153
|
+
* @param input.ignoreBlockList - Whether to ignore the blocklist (default: true)
|
|
154
|
+
* @returns ResolveModelResult with model info and match type, or failure reason
|
|
155
|
+
*/
|
|
156
|
+
resolveModel(input: {
|
|
157
|
+
providerId?: string;
|
|
158
|
+
model: string;
|
|
159
|
+
ignoreBlockList?: boolean;
|
|
160
|
+
}): ResolveModelResult;
|
|
161
|
+
/**
|
|
162
|
+
* Check if a model is available (provider exists and is healthy).
|
|
163
|
+
*/
|
|
164
|
+
isModelAvailable(modelName: string): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Get all available models.
|
|
167
|
+
*/
|
|
168
|
+
getAvailableModels(): string[];
|
|
169
|
+
/**
|
|
170
|
+
* Get provider status information.
|
|
171
|
+
*/
|
|
172
|
+
getProviderStatus(): Map<string, ProviderStatus>;
|
|
173
|
+
/**
|
|
174
|
+
* Calculate cost for a given token usage with full cache support.
|
|
175
|
+
*
|
|
176
|
+
* Handles provider-specific token semantics:
|
|
177
|
+
* - OpenAI: inputTokens INCLUDES cached tokens (cache_read is a subset)
|
|
178
|
+
* - Anthropic: inputTokens is fresh only (cache_read is additive)
|
|
179
|
+
*
|
|
180
|
+
* @param modelName - Model identifier (will be resolved via registry)
|
|
181
|
+
* @param usage - Token usage breakdown
|
|
182
|
+
* @returns Cost in USD, or null if model not found or no pricing data available
|
|
183
|
+
*/
|
|
184
|
+
calculateCost(modelName: string, usage: {
|
|
185
|
+
inputTokens: number;
|
|
186
|
+
outputTokens: number;
|
|
187
|
+
cacheReadTokens?: number;
|
|
188
|
+
cacheCreationTokens?: number;
|
|
189
|
+
}): number | null;
|
|
190
|
+
/**
|
|
191
|
+
* Format cost as a readable string.
|
|
192
|
+
*/
|
|
193
|
+
formatCost(cost: number): string;
|
|
194
|
+
/**
|
|
195
|
+
* Get models for a specific provider
|
|
196
|
+
*/
|
|
197
|
+
getModelsForProvider(providerId: string): string[];
|
|
198
|
+
/**
|
|
199
|
+
* Get summary statistics
|
|
200
|
+
*/
|
|
201
|
+
getStats(): {
|
|
202
|
+
totalModels: number;
|
|
203
|
+
totalProviders: number;
|
|
204
|
+
availableProviders: number;
|
|
205
|
+
healthyProviders: number;
|
|
206
|
+
};
|
|
207
|
+
}
|