@compilr-dev/sdk 0.17.6 → 0.17.8
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 +9 -3
- package/package.json +2 -2
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' +
|
|
@@ -35,11 +35,16 @@ export const canvasSkill = defineSkill({
|
|
|
35
35
|
|
|
36
36
|
1. **Clarify only if needed.** If the request is concrete, go straight to authoring. If the subject or type is ambiguous, ask ONE short question (what should it show, or which type) — do not run a long interview.
|
|
37
37
|
|
|
38
|
-
2. **
|
|
38
|
+
2. **Build the canvas in small steps — never one giant tool call.** A canvas is HTML/SVG you emit as tool arguments; a single very large \`canvas_write\` can overrun the output limit, get cut off mid-arguments, and fail. So author it incrementally, and emit each tool call immediately with NO prose preamble (narration competes with the HTML for the same output budget):
|
|
39
|
+
- **2a. First \`canvas_write\`** (type, title, html) = a COMPACT skeleton: the \`<style>\` block, the overall layout, and just the first section or heading. This is the ONLY way to create a canvas — describing it in chat does nothing.
|
|
40
|
+
- **2b. Then \`canvas_edit\` (operation=append)** to add each remaining section, one call per section. The preview grows as you go, and every call stays small and reliable. (You can also leave \`<!-- placeholder -->\` markers in 2a and str_replace them.)
|
|
41
|
+
- Put the whole thing in one \`canvas_write\` ONLY if it is genuinely small (a single stat card / short poster).
|
|
42
|
+
|
|
43
|
+
HTML constraints for every write:
|
|
39
44
|
- Do NOT include \`<html>\`, \`<head>\`, \`<meta>\`, \`<!doctype>\`, or your own CSP — the host injects the sandbox and CSP. Just the body content + a \`<style>\` and optional \`<script>\`.
|
|
40
45
|
- 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
46
|
- Make it look intentional: a clear grid, strong type scale, generous spacing, a small cohesive palette. Prefer inline SVG for shapes/charts/icons.
|
|
42
|
-
- For a **carousel**, wrap each slide in \`<section data-sheet>…</section
|
|
47
|
+
- For a **carousel**, wrap each slide in \`<section data-sheet>…</section>\` — a natural unit to add one per \`canvas_edit\` append.
|
|
43
48
|
|
|
44
49
|
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
50
|
- CSS custom property: use \`var(--param)\` in your styles (the host sets \`--param\` on the root).
|
|
@@ -53,7 +58,8 @@ export const canvasSkill = defineSkill({
|
|
|
53
58
|
5. **After writing, tell the user what you made in one line** and point them at the Tweaks they can adjust. The canvas opens in its own tab.
|
|
54
59
|
|
|
55
60
|
## Rules
|
|
56
|
-
- CALL THE TOOL
|
|
61
|
+
- CALL THE TOOL — don't describe the HTML you "would" write and stop. A canvas only exists once the tool succeeds.
|
|
62
|
+
- Keep every tool call SMALL. Emit \`canvas_write\`/\`canvas_edit\` with no prose preamble, and split rich canvases across several small calls (step 2). One huge call risks being cut off at the output limit.
|
|
57
63
|
- Keep \`html\` self-contained and within the sandbox limits above — anything that needs the network or same-origin will silently fail to render.
|
|
58
64
|
- One canvas per request unless the user asks for several.`,
|
|
59
65
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compilr-dev/sdk",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.8",
|
|
4
4
|
"description": "Universal agent runtime for building AI-powered applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"node": ">=20.0.0"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@compilr-dev/agents": "^0.6.
|
|
75
|
+
"@compilr-dev/agents": "^0.6.1",
|
|
76
76
|
"@compilr-dev/logger": "^0.1.0",
|
|
77
77
|
"ajv": "^6.14.0",
|
|
78
78
|
"yaml": "^2.8.4"
|