@compilr-dev/sdk 0.17.6 → 0.17.7
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/dist/agent.js +1 -0
- package/dist/config.d.ts +5 -0
- package/dist/provider.d.ts +5 -0
- package/dist/provider.js +13 -10
- package/dist/skills/canvas-skills.js +1 -0
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -100,6 +100,7 @@ class CompilrAgentImpl {
|
|
|
100
100
|
model: config?.model,
|
|
101
101
|
apiKey: config?.apiKey,
|
|
102
102
|
extendedContext: config?.context?.extendedContext,
|
|
103
|
+
maxTokens: config?.maxTokens,
|
|
103
104
|
});
|
|
104
105
|
// Resolve preset — non-software projects get 'general' by default
|
|
105
106
|
const defaultPreset = config?.projectCategory && config.projectCategory !== 'software' ? 'general' : 'coding';
|
package/dist/config.d.ts
CHANGED
|
@@ -199,6 +199,11 @@ export interface CompilrAgentConfig {
|
|
|
199
199
|
model?: string;
|
|
200
200
|
/** API key (uses env var if omitted) */
|
|
201
201
|
apiKey?: string;
|
|
202
|
+
/** Default max OUTPUT tokens per LLM call. Providers default to 4096, which
|
|
203
|
+
* truncates large single tool calls (e.g. authoring a full canvas) — raise
|
|
204
|
+
* it for hosts that emit big tool payloads. Stays within the model's own
|
|
205
|
+
* output limit; do not exceed it. */
|
|
206
|
+
maxTokens?: number;
|
|
202
207
|
/** Preset to use. Default: 'coding' (or 'general' for non-software projectCategory) */
|
|
203
208
|
preset?: 'coding' | 'general' | 'read-only' | 'none' | Preset;
|
|
204
209
|
/** Project type category — determines default preset when preset is omitted */
|
package/dist/provider.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ export declare function createProviderFromType(type: ProviderType, options?: {
|
|
|
18
18
|
siteName?: string;
|
|
19
19
|
estimateTokens?: (text: string) => number;
|
|
20
20
|
extendedContext?: boolean;
|
|
21
|
+
/** Default max OUTPUT tokens per call. Providers default to 4096, which is
|
|
22
|
+
* too low for large single tool calls (e.g. authoring a full canvas). */
|
|
23
|
+
maxTokens?: number;
|
|
21
24
|
}): LLMProvider;
|
|
22
25
|
/**
|
|
23
26
|
* Resolve a provider from config.
|
|
@@ -28,4 +31,6 @@ export declare function resolveProvider(config?: {
|
|
|
28
31
|
model?: string;
|
|
29
32
|
apiKey?: string;
|
|
30
33
|
extendedContext?: boolean;
|
|
34
|
+
/** Default max OUTPUT tokens per call (forwarded to the provider). */
|
|
35
|
+
maxTokens?: number;
|
|
31
36
|
}): LLMProvider;
|
package/dist/provider.js
CHANGED
|
@@ -32,7 +32,7 @@ export function detectProviderFromEnv() {
|
|
|
32
32
|
* Create an LLM provider from a provider type string.
|
|
33
33
|
*/
|
|
34
34
|
export function createProviderFromType(type, options) {
|
|
35
|
-
const { model, apiKey, baseUrl, siteName, estimateTokens, extendedContext } = options ?? {};
|
|
35
|
+
const { model, apiKey, baseUrl, siteName, estimateTokens, extendedContext, maxTokens } = options ?? {};
|
|
36
36
|
switch (type) {
|
|
37
37
|
case 'claude':
|
|
38
38
|
return createClaudeProvider({
|
|
@@ -40,26 +40,27 @@ export function createProviderFromType(type, options) {
|
|
|
40
40
|
apiKey,
|
|
41
41
|
estimateTokens,
|
|
42
42
|
enableExtendedContext: extendedContext,
|
|
43
|
+
maxTokens,
|
|
43
44
|
});
|
|
44
45
|
case 'openai':
|
|
45
|
-
return createOpenAIProvider({ model, apiKey, estimateTokens });
|
|
46
|
+
return createOpenAIProvider({ model, apiKey, estimateTokens, maxTokens });
|
|
46
47
|
case 'gemini':
|
|
47
|
-
return createGeminiNativeProvider({ model, apiKey, estimateTokens });
|
|
48
|
+
return createGeminiNativeProvider({ model, apiKey, estimateTokens, maxTokens });
|
|
48
49
|
case 'ollama':
|
|
49
|
-
return createOllamaProvider({ model, baseUrl, estimateTokens });
|
|
50
|
+
return createOllamaProvider({ model, baseUrl, estimateTokens, maxTokens });
|
|
50
51
|
case 'together':
|
|
51
|
-
return createTogetherProvider({ model, apiKey, estimateTokens });
|
|
52
|
+
return createTogetherProvider({ model, apiKey, estimateTokens, maxTokens });
|
|
52
53
|
case 'groq':
|
|
53
|
-
return createGroqProvider({ model, apiKey, estimateTokens });
|
|
54
|
+
return createGroqProvider({ model, apiKey, estimateTokens, maxTokens });
|
|
54
55
|
case 'fireworks':
|
|
55
|
-
return createFireworksProvider({ model, apiKey, estimateTokens });
|
|
56
|
+
return createFireworksProvider({ model, apiKey, estimateTokens, maxTokens });
|
|
56
57
|
case 'perplexity':
|
|
57
|
-
return createPerplexityProvider({ model, apiKey, estimateTokens });
|
|
58
|
+
return createPerplexityProvider({ model, apiKey, estimateTokens, maxTokens });
|
|
58
59
|
case 'openrouter':
|
|
59
|
-
return createOpenRouterProvider({ model, apiKey, siteName, estimateTokens });
|
|
60
|
+
return createOpenRouterProvider({ model, apiKey, siteName, estimateTokens, maxTokens });
|
|
60
61
|
case 'custom':
|
|
61
62
|
// Custom endpoints use OpenAI-compatible format
|
|
62
|
-
return createOpenAIProvider({ model, apiKey, estimateTokens });
|
|
63
|
+
return createOpenAIProvider({ model, apiKey, estimateTokens, maxTokens });
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
@@ -77,6 +78,7 @@ export function resolveProvider(config) {
|
|
|
77
78
|
model: config.model,
|
|
78
79
|
apiKey: config.apiKey,
|
|
79
80
|
extendedContext: config.extendedContext,
|
|
81
|
+
maxTokens: config.maxTokens,
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
// Auto-detect from env
|
|
@@ -86,6 +88,7 @@ export function resolveProvider(config) {
|
|
|
86
88
|
model: config?.model,
|
|
87
89
|
apiKey: config?.apiKey,
|
|
88
90
|
extendedContext: config?.extendedContext,
|
|
91
|
+
maxTokens: config?.maxTokens,
|
|
89
92
|
});
|
|
90
93
|
}
|
|
91
94
|
throw new Error('No LLM provider configured. Either:\n' +
|
|
@@ -40,6 +40,7 @@ export const canvasSkill = defineSkill({
|
|
|
40
40
|
- The sandbox is \`allow-scripts\` with NO same-origin and CSP \`default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:\`. So: inline \`<style>\`/\`<script>\` only, no external fonts/CSS/JS/network, no remote images (use inline SVG or data: URIs).
|
|
41
41
|
- Make it look intentional: a clear grid, strong type scale, generous spacing, a small cohesive palette. Prefer inline SVG for shapes/charts/icons.
|
|
42
42
|
- For a **carousel**, wrap each slide in \`<section data-sheet>…</section>\`.
|
|
43
|
+
- **Build in steps for anything rich — do NOT try to emit a huge HTML document in one canvas_write.** A single very large tool call can be truncated and silently dropped. Instead: first \`canvas_write\` a COMPACT version — the \`<style>\` block plus the overall structure and the first section or two. Then use \`canvas_edit\` (operation=append, or str_replace to fill placeholders) to add the remaining sections one at a time. Each call stays small and reliable, and the preview grows as you go.
|
|
43
44
|
|
|
44
45
|
3. **Add a Tweaks controls manifest when it helps** (the \`controls\` argument). Each control is \`{ type, param, label, default, …type config }\` where type ∈ slider | number | toggle | select | color | text. Bind params in your HTML three ways:
|
|
45
46
|
- CSS custom property: use \`var(--param)\` in your styles (the host sets \`--param\` on the root).
|