@sudobility/shapeshyft_engine 1.0.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/CLAUDE.md +27 -0
- package/README.md +11 -0
- package/dist/config/providers.d.ts +111 -0
- package/dist/config/providers.d.ts.map +1 -0
- package/dist/config/providers.js +1535 -0
- package/dist/config/providers.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-helper.d.ts +35 -0
- package/dist/lib/api-helper.d.ts.map +1 -0
- package/dist/lib/api-helper.js +123 -0
- package/dist/lib/api-helper.js.map +1 -0
- package/dist/lib/capability-validator.d.ts +36 -0
- package/dist/lib/capability-validator.d.ts.map +1 -0
- package/dist/lib/capability-validator.js +140 -0
- package/dist/lib/capability-validator.js.map +1 -0
- package/dist/lib/media-constants.d.ts +55 -0
- package/dist/lib/media-constants.d.ts.map +1 -0
- package/dist/lib/media-constants.js +166 -0
- package/dist/lib/media-constants.js.map +1 -0
- package/dist/lib/media-conversion.d.ts +36 -0
- package/dist/lib/media-conversion.d.ts.map +1 -0
- package/dist/lib/media-conversion.js +87 -0
- package/dist/lib/media-conversion.js.map +1 -0
- package/dist/lib/media-utils.d.ts +35 -0
- package/dist/lib/media-utils.d.ts.map +1 -0
- package/dist/lib/media-utils.js +173 -0
- package/dist/lib/media-utils.js.map +1 -0
- package/dist/lib/output-limit.d.ts +38 -0
- package/dist/lib/output-limit.d.ts.map +1 -0
- package/dist/lib/output-limit.js +54 -0
- package/dist/lib/output-limit.js.map +1 -0
- package/dist/lib/prompt-builder.d.ts +94 -0
- package/dist/lib/prompt-builder.d.ts.map +1 -0
- package/dist/lib/prompt-builder.js +408 -0
- package/dist/lib/prompt-builder.js.map +1 -0
- package/dist/lib/reserved-fields.d.ts +41 -0
- package/dist/lib/reserved-fields.d.ts.map +1 -0
- package/dist/lib/reserved-fields.js +47 -0
- package/dist/lib/reserved-fields.js.map +1 -0
- package/dist/services/llm/anthropic.d.ts +16 -0
- package/dist/services/llm/anthropic.d.ts.map +1 -0
- package/dist/services/llm/anthropic.js +154 -0
- package/dist/services/llm/anthropic.js.map +1 -0
- package/dist/services/llm/custom.d.ts +51 -0
- package/dist/services/llm/custom.d.ts.map +1 -0
- package/dist/services/llm/custom.js +419 -0
- package/dist/services/llm/custom.js.map +1 -0
- package/dist/services/llm/extract-json.d.ts +17 -0
- package/dist/services/llm/extract-json.d.ts.map +1 -0
- package/dist/services/llm/extract-json.js +60 -0
- package/dist/services/llm/extract-json.js.map +1 -0
- package/dist/services/llm/finish-reason.d.ts +21 -0
- package/dist/services/llm/finish-reason.d.ts.map +1 -0
- package/dist/services/llm/finish-reason.js +55 -0
- package/dist/services/llm/finish-reason.js.map +1 -0
- package/dist/services/llm/gemini.d.ts +26 -0
- package/dist/services/llm/gemini.d.ts.map +1 -0
- package/dist/services/llm/gemini.js +178 -0
- package/dist/services/llm/gemini.js.map +1 -0
- package/dist/services/llm/groq.d.ts +28 -0
- package/dist/services/llm/groq.d.ts.map +1 -0
- package/dist/services/llm/groq.js +237 -0
- package/dist/services/llm/groq.js.map +1 -0
- package/dist/services/llm/index.d.ts +19 -0
- package/dist/services/llm/index.d.ts.map +1 -0
- package/dist/services/llm/index.js +88 -0
- package/dist/services/llm/index.js.map +1 -0
- package/dist/services/llm/openai.d.ts +101 -0
- package/dist/services/llm/openai.d.ts.map +1 -0
- package/dist/services/llm/openai.js +561 -0
- package/dist/services/llm/openai.js.map +1 -0
- package/dist/services/llm/types.d.ts +110 -0
- package/dist/services/llm/types.d.ts.map +1 -0
- package/dist/services/llm/types.js +16 -0
- package/dist/services/llm/types.js.map +1 -0
- package/dist/types/index.d.ts +812 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +366 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +93 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# shapeshyft_engine
|
|
2
|
+
|
|
3
|
+
> **Git policy — never auto-commit or auto-push.** Run `git commit`, `git push`,
|
|
4
|
+
> or publish only when the user explicitly asks in that turn.
|
|
5
|
+
|
|
6
|
+
Stateless core shared by `shapeshyft_api` and `shaperouter_api` (via
|
|
7
|
+
`@sudobility/shapeshyft_service`). No database, no Hono, no `process.env`.
|
|
8
|
+
|
|
9
|
+
## Entry points
|
|
10
|
+
|
|
11
|
+
- `@sudobility/shapeshyft_engine` — `createLLMProvider`, provider adapters,
|
|
12
|
+
provider/model catalog (`config/providers`), prompt builder, `ApiHelper`,
|
|
13
|
+
media handling, capability validation, reserved fields, output limits.
|
|
14
|
+
- `@sudobility/shapeshyft_engine/types` — domain types and pure helpers. Must
|
|
15
|
+
never gain a runtime `import`; `tests/unit/types-no-runtime-imports.test.ts`
|
|
16
|
+
enforces it. Frontend packages (`shapeshyft_types`, `shaperouter_types`)
|
|
17
|
+
re-export this.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- Relative imports carry `.js` (`NodeNext`). The compiler rejects them otherwise.
|
|
22
|
+
- Provider SDKs and `sharp` are optional peer dependencies.
|
|
23
|
+
- Provider credentials arrive in `ProviderConfig`; the engine never looks them up.
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
26
|
+
|
|
27
|
+
bun run verify # typecheck + lint + test + build
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @sudobility/shapeshyft_engine
|
|
2
|
+
|
|
3
|
+
Stateless LLM structured-output engine used by ShapeShyft and ShapeRouter.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createLLMProvider } from "@sudobility/shapeshyft_engine";
|
|
7
|
+
import type { LlmProvider } from "@sudobility/shapeshyft_engine/types";
|
|
8
|
+
|
|
9
|
+
const provider = createLLMProvider("openai", { apiKey });
|
|
10
|
+
const result = await provider.generate(request);
|
|
11
|
+
```
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Provider and Model Configuration
|
|
3
|
+
*
|
|
4
|
+
* This configuration is served via API endpoints so it can be updated
|
|
5
|
+
* without requiring frontend package updates.
|
|
6
|
+
*
|
|
7
|
+
* ## Supported Providers
|
|
8
|
+
*
|
|
9
|
+
* Catalog verified against provider documentation on 2026-08-18.
|
|
10
|
+
*
|
|
11
|
+
* - **openai**: GPT-5.6 (Sol/Terra/Luna), GPT-5.5, GPT-5.4, GPT-5, GPT-4.1, GPT-4o
|
|
12
|
+
* - **anthropic**: Claude Fable 5, Opus 5, Sonnet 5, Haiku 4.5 (+ Opus 4.8/4.7/4.6, Sonnet 4.6)
|
|
13
|
+
* - **gemini**: Gemini 3.7/3.6/3.5/3.1 and 2.5, Nano Banana image models, Veo 3.1 video
|
|
14
|
+
* - **mistral**: Mistral Large 3, Medium 3.5, Small 4, Ministral 3, Codestral, OCR
|
|
15
|
+
* - **cohere**: Command A+, Command A (reasoning/vision/translate), Command R
|
|
16
|
+
* - **groq**: GPT-OSS, Qwen3.6, MiniMax M2.7, Compound, Whisper
|
|
17
|
+
* - **xai**: Grok 4.6, 4.5, 4.3, Grok 4.20 variants, Grok Build
|
|
18
|
+
* - **deepseek**: DeepSeek V4 Pro and V4 Flash
|
|
19
|
+
* - **perplexity**: Sonar models with live web search grounding
|
|
20
|
+
* - **lm_studio**: Local LLM server (LM Studio or any OpenAI-compatible endpoint)
|
|
21
|
+
*
|
|
22
|
+
* ## Keeping this current
|
|
23
|
+
*
|
|
24
|
+
* Model lineups turn over every few weeks and retired IDs fail at the provider,
|
|
25
|
+
* not here -- `MODEL_CAPABILITIES` and `MODEL_PRICING` fall back to permissive
|
|
26
|
+
* defaults for anything unknown, so a stale entry surfaces as a runtime error in
|
|
27
|
+
* a user's endpoint. When updating, work from each provider's own model and
|
|
28
|
+
* pricing pages (linked above each section below), and check the provider's
|
|
29
|
+
* deprecation page for retirements: Groq retired `llama-3.3-70b-versatile` and
|
|
30
|
+
* `llama-3.1-8b-instant` on 2026-08-16, and both were listed here until then.
|
|
31
|
+
*
|
|
32
|
+
* Pricing is in **cents per 1M tokens** (image per image, audio/video per minute).
|
|
33
|
+
*
|
|
34
|
+
* ## LM Studio Model Identifiers
|
|
35
|
+
*
|
|
36
|
+
* LM Studio uses the OpenAI-compatible API format. When specifying models:
|
|
37
|
+
*
|
|
38
|
+
* - **API requests** use just the model name (e.g., `"qwen2.5-vl-7b-instruct"`)
|
|
39
|
+
* - **Downloading models** uses publisher/name format (e.g., `lmstudio-community/Qwen2.5-VL-7B-Instruct-GGUF`)
|
|
40
|
+
*
|
|
41
|
+
* The model identifier in API requests matches what's returned by `GET /v1/models`.
|
|
42
|
+
* Example response:
|
|
43
|
+
* ```json
|
|
44
|
+
* { "id": "qwen2.5-vl-7b-instruct", "object": "model" }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* To discover available models on a running LM Studio server:
|
|
48
|
+
* ```bash
|
|
49
|
+
* curl http://localhost:1234/v1/models
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* For multi-variant models, you can specify quantization with `@`:
|
|
53
|
+
* ```
|
|
54
|
+
* google/gemma-3-12b@q3_k_l
|
|
55
|
+
* google/gemma-3-12b@4bit
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* ## Vision Models
|
|
59
|
+
*
|
|
60
|
+
* Vision-capable models can process images in addition to text:
|
|
61
|
+
* - Qwen2.5-VL series: Excellent object recognition, 128k context window
|
|
62
|
+
* - Gemma 3 series: Google's multimodal models
|
|
63
|
+
* - GLM-4V: Optimized for local deployment
|
|
64
|
+
* - Pixtral: Mistral's vision model
|
|
65
|
+
* - olmOCR: Specialized for OCR tasks
|
|
66
|
+
* - Janus-Pro: Visual QA and scene interpretation
|
|
67
|
+
*
|
|
68
|
+
* Note: Vision models are not optimal for text-only tasks. For text-only
|
|
69
|
+
* workloads, use dedicated text models like Qwen3 or Mistral.
|
|
70
|
+
*
|
|
71
|
+
* @see https://lmstudio.ai/docs/developer/openai-compat
|
|
72
|
+
* @see https://lmstudio.ai/docs/developer/openai-compat/models
|
|
73
|
+
*/
|
|
74
|
+
import type { LlmProvider, ModelCapabilities, ModelPricing, ProviderConfig } from "../types/index.js";
|
|
75
|
+
export declare const PROVIDERS: ProviderConfig[];
|
|
76
|
+
export declare const PROVIDER_MODELS: Record<LlmProvider, string[]>;
|
|
77
|
+
export declare const MODEL_CAPABILITIES: Record<string, ModelCapabilities>;
|
|
78
|
+
export declare const MODEL_PRICING: Record<string, ModelPricing>;
|
|
79
|
+
export declare const DEFAULT_MODEL_PRICING: ModelPricing;
|
|
80
|
+
/**
|
|
81
|
+
* Get provider configuration by ID.
|
|
82
|
+
* @param providerId - The provider identifier (e.g., "openai", "anthropic")
|
|
83
|
+
* @returns The provider config or undefined if not found
|
|
84
|
+
*/
|
|
85
|
+
export declare function getProviderById(providerId: LlmProvider): ProviderConfig | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Get the list of model IDs for a given provider.
|
|
88
|
+
* @param providerId - The provider identifier
|
|
89
|
+
* @returns Array of model ID strings
|
|
90
|
+
*/
|
|
91
|
+
export declare function getModelsForProvider(providerId: LlmProvider): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Get capabilities for a specific model (vision, audio, video I/O).
|
|
94
|
+
* Returns empty object for unknown models (permissive by default).
|
|
95
|
+
* @param model - The model identifier
|
|
96
|
+
* @returns Model capabilities
|
|
97
|
+
*/
|
|
98
|
+
export declare function getModelCapabilities(model: string): ModelCapabilities;
|
|
99
|
+
/**
|
|
100
|
+
* Get pricing for a specific model (cents per 1M tokens).
|
|
101
|
+
* Returns DEFAULT_MODEL_PRICING for unknown models.
|
|
102
|
+
* @param model - The model identifier
|
|
103
|
+
* @returns Model pricing
|
|
104
|
+
*/
|
|
105
|
+
export declare function getModelPricing(model: string): ModelPricing;
|
|
106
|
+
/**
|
|
107
|
+
* Get the provider for a given model name.
|
|
108
|
+
* Searches through PROVIDER_MODELS to find which provider owns this model.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getProviderForModel(model: string): LlmProvider;
|
|
111
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/config/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACf,MAAM,mBAAmB,CAAC;AAM3B,eAAO,MAAM,SAAS,EAAE,cAAc,EAoFrC,CAAC;AAMF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CA2JzD,CAAC;AAMF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAs8BhE,CAAC;AAMF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CA6MtD,CAAC;AAGF,eAAO,MAAM,qBAAqB,EAAE,YAA0C,CAAC;AAM/E;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,WAAW,GACtB,cAAc,GAAG,SAAS,CAE5B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAK3D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAQ9D"}
|