@compilr-dev/sdk 0.17.5 → 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/capabilities/packs.js +11 -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.d.ts +7 -0
- package/dist/skills/canvas-skills.js +60 -0
- package/dist/skills/platform-skills.d.ts +2 -1
- package/dist/skills/platform-skills.js +6 -1
- package/dist/team/tool-config.js +13 -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';
|
|
@@ -233,6 +233,16 @@ export const CAPABILITY_PACKS = {
|
|
|
233
233
|
estimatedPromptTokens: 150,
|
|
234
234
|
estimatedToolTokens: 1500,
|
|
235
235
|
},
|
|
236
|
+
canvas: {
|
|
237
|
+
id: 'canvas',
|
|
238
|
+
label: 'Visual Canvas',
|
|
239
|
+
tools: ['canvas_write', 'canvas_edit', 'canvas_list', 'canvas_get', 'canvas_delete'],
|
|
240
|
+
readOnly: false,
|
|
241
|
+
promptModules: ['platform-tool-hints'],
|
|
242
|
+
promptSnippet: 'Visual canvases (infographic/carousel/board) rendered from sandboxed HTML/SVG. Create/replace with canvas_write (raw HTML only — host injects the CSP; inline <style>/<script> only, no network/remote assets; optional Tweaks controls manifest). EDIT via canvas_get (outline=true or startLine/maxLines) then canvas_edit (str_replace/append/prepend) — never re-send the whole document.',
|
|
243
|
+
estimatedPromptTokens: 150,
|
|
244
|
+
estimatedToolTokens: 1500,
|
|
245
|
+
},
|
|
236
246
|
plans: {
|
|
237
247
|
id: 'plans',
|
|
238
248
|
label: 'Planning',
|
|
@@ -443,6 +453,7 @@ export const FORBIDDEN_PACK_SUGGESTIONS = {
|
|
|
443
453
|
backlog_write: '$pm',
|
|
444
454
|
backlog_read: '$pm',
|
|
445
455
|
documents: '$pm',
|
|
456
|
+
canvas: '$default',
|
|
446
457
|
plans: '$pm',
|
|
447
458
|
search: '$arch',
|
|
448
459
|
dependencies: '$arch',
|
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' +
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Skills
|
|
3
|
+
*
|
|
4
|
+
* canvas — author and edit a visual canvas (infographic, carousel, or board)
|
|
5
|
+
* rendered from sandboxed HTML/SVG, optionally with live "Tweaks" controls.
|
|
6
|
+
*/
|
|
7
|
+
import { defineSkill } from '@compilr-dev/agents';
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// /canvas — visual canvas authoring
|
|
10
|
+
// =============================================================================
|
|
11
|
+
export const canvasSkill = defineSkill({
|
|
12
|
+
name: 'canvas',
|
|
13
|
+
description: 'Author or edit a visual canvas — an infographic, a slide carousel, or an infinite board — rendered ' +
|
|
14
|
+
'from HTML/SVG in a sandboxed preview, optionally with live "Tweaks" controls the user can adjust. ' +
|
|
15
|
+
'Use when the user wants something visual: a diagram, poster, stat card, one-pager, slide deck, or ' +
|
|
16
|
+
'explainer graphic, rather than prose or a code file.',
|
|
17
|
+
tags: ['visual', 'canvas', 'design'],
|
|
18
|
+
prompt: `You are in CANVAS MODE. Your job is to produce a VISUAL artifact — a rendered HTML/SVG canvas — not prose and not a code file. The canvas renders in a sandboxed preview and can carry live "Tweaks" the user adjusts.
|
|
19
|
+
|
|
20
|
+
## When to Use
|
|
21
|
+
- The user wants something visual: infographic, poster, stat card, one-pager, diagram, explainer, slide deck.
|
|
22
|
+
- The user says "make a canvas", "visualize this", "turn this into slides", "draw me a…".
|
|
23
|
+
|
|
24
|
+
## When NOT to Use
|
|
25
|
+
- They want prose (a doc, PRD, notes) → use the document tools / relevant writing skill.
|
|
26
|
+
- They want real application code/files on disk → use write_file / build.
|
|
27
|
+
- They want a data model → use the factory model tools.
|
|
28
|
+
|
|
29
|
+
## Canvas types (pick one)
|
|
30
|
+
- **infographic** — a single self-contained composition (poster / stat card / one-pager). Default when unsure.
|
|
31
|
+
- **carousel** — multiple slide "sheets"; author each slide as a top-level \`<section data-sheet>…</section>\`.
|
|
32
|
+
- **board** — an infinite 2D board of loosely-placed elements.
|
|
33
|
+
|
|
34
|
+
## STEPS
|
|
35
|
+
|
|
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
|
+
|
|
38
|
+
2. **Author the content with canvas_write** (type, title, html). This is the ONLY way to create a canvas — describing it in chat does nothing. Write raw HTML/SVG for the \`html\` field:
|
|
39
|
+
- 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
|
+
- 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
|
+
- 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>\`.
|
|
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.
|
|
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:
|
|
46
|
+
- CSS custom property: use \`var(--param)\` in your styles (the host sets \`--param\` on the root).
|
|
47
|
+
- Text binding: \`<span data-bind="param"></span>\` gets replaced with the value.
|
|
48
|
+
- Visibility: \`[data-show="param"]\` shows/hides based on a toggle.
|
|
49
|
+
- For computed updates, define \`window.applyParams(values)\` in a \`<script>\` and read \`values.param\`.
|
|
50
|
+
Give every canvas at least 2–4 sensible controls (accent color, a headline size slider, a toggle to show/hide a section) so the user has something to play with. Seed \`default\` values that match what you authored.
|
|
51
|
+
|
|
52
|
+
4. **To EDIT an existing canvas, do NOT re-send the whole document.** First call \`canvas_get\` with \`outline=true\` (or a \`startLine\`/\`maxLines\` slice) to find the exact snippet, then \`canvas_edit\` with \`operation=str_replace\` (old_str must be unique — include surrounding context — or set replace_all=true), or append/prepend. Reserve \`canvas_write\` with \`canvas_id\` for a full intentional rewrite.
|
|
53
|
+
|
|
54
|
+
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.
|
|
55
|
+
|
|
56
|
+
## Rules
|
|
57
|
+
- CALL THE TOOL. Do not describe the HTML you "would" write and stop — emit \`canvas_write\` with real content. A canvas only exists once the tool succeeds.
|
|
58
|
+
- Keep \`html\` self-contained and within the sandbox limits above — anything that needs the network or same-origin will silently fail to render.
|
|
59
|
+
- One canvas per request unless the user asks for several.`,
|
|
60
|
+
});
|
|
@@ -11,7 +11,8 @@ export { businessVisionSkill, marketAnalysisSkill, competitorAnalysisSkill, fina
|
|
|
11
11
|
export { brandSetupSkill, contentStrategySkill, contentCalendarSkill, createContentSkill, contentReviewSkill, } from './content-skills.js';
|
|
12
12
|
export { curriculumDesignSkill, lessonPlanSkill, assessmentDesignSkill, courseReviewSkill, } from './course-skills.js';
|
|
13
13
|
export { bookOutlineSkill, characterDesignSkill, plotThreadsSkill, sceneBreakdownSkill, bookReviewSkill, } from './book-skills.js';
|
|
14
|
+
export { canvasSkill } from './canvas-skills.js';
|
|
14
15
|
/**
|
|
15
|
-
* All platform-specific skills (
|
|
16
|
+
* All platform-specific skills (35 total).
|
|
16
17
|
*/
|
|
17
18
|
export declare const platformSkills: Skill[];
|
|
@@ -16,6 +16,8 @@ export { brandSetupSkill, contentStrategySkill, contentCalendarSkill, createCont
|
|
|
16
16
|
export { curriculumDesignSkill, lessonPlanSkill, assessmentDesignSkill, courseReviewSkill, } from './course-skills.js';
|
|
17
17
|
// Book
|
|
18
18
|
export { bookOutlineSkill, characterDesignSkill, plotThreadsSkill, sceneBreakdownSkill, bookReviewSkill, } from './book-skills.js';
|
|
19
|
+
// Canvas (visual)
|
|
20
|
+
export { canvasSkill } from './canvas-skills.js';
|
|
19
21
|
// Import all for the aggregate array
|
|
20
22
|
import { designSkill, sketchSkill, prdSkill, refineSkill, refineItemSkill, architectureSkill, sessionNotesSkill, buildSkill, scaffoldSkill, } from './software-skills.js';
|
|
21
23
|
import { outlineSkill, literatureReviewSkill, draftSectionSkill, peerReviewSkill, researchScaffoldSkill, } from './research-skills.js';
|
|
@@ -23,8 +25,9 @@ import { businessVisionSkill, marketAnalysisSkill, competitorAnalysisSkill, fina
|
|
|
23
25
|
import { brandSetupSkill, contentStrategySkill, contentCalendarSkill, createContentSkill, contentReviewSkill, } from './content-skills.js';
|
|
24
26
|
import { curriculumDesignSkill, lessonPlanSkill, assessmentDesignSkill, courseReviewSkill, } from './course-skills.js';
|
|
25
27
|
import { bookOutlineSkill, characterDesignSkill, plotThreadsSkill, sceneBreakdownSkill, bookReviewSkill, } from './book-skills.js';
|
|
28
|
+
import { canvasSkill } from './canvas-skills.js';
|
|
26
29
|
/**
|
|
27
|
-
* All platform-specific skills (
|
|
30
|
+
* All platform-specific skills (35 total).
|
|
28
31
|
*/
|
|
29
32
|
export const platformSkills = [
|
|
30
33
|
// Software (9)
|
|
@@ -67,4 +70,6 @@ export const platformSkills = [
|
|
|
67
70
|
plotThreadsSkill,
|
|
68
71
|
sceneBreakdownSkill,
|
|
69
72
|
bookReviewSkill,
|
|
73
|
+
// Canvas (1)
|
|
74
|
+
canvasSkill,
|
|
70
75
|
];
|
package/dist/team/tool-config.js
CHANGED
|
@@ -284,6 +284,14 @@ export const TOOL_GROUPS = {
|
|
|
284
284
|
readOnly: false,
|
|
285
285
|
tier: 'meta',
|
|
286
286
|
},
|
|
287
|
+
canvas: {
|
|
288
|
+
label: 'Visual Canvas',
|
|
289
|
+
// Canvas tools are defined in @compilr-dev/sdk (createPlatformTools), not in
|
|
290
|
+
// the agents-lib TOOL_NAMES registry, so they are referenced by literal name.
|
|
291
|
+
tools: ['canvas_write', 'canvas_edit', 'canvas_list', 'canvas_get', 'canvas_delete'],
|
|
292
|
+
readOnly: false,
|
|
293
|
+
tier: 'meta',
|
|
294
|
+
},
|
|
287
295
|
plans: {
|
|
288
296
|
label: 'Planning',
|
|
289
297
|
tools: [
|
|
@@ -514,6 +522,7 @@ export const TOOL_PROFILES = {
|
|
|
514
522
|
'backlog_read',
|
|
515
523
|
'backlog_write',
|
|
516
524
|
'documents',
|
|
525
|
+
'canvas',
|
|
517
526
|
'plans',
|
|
518
527
|
'artifacts',
|
|
519
528
|
'anchors',
|
|
@@ -553,6 +562,7 @@ export const TOOL_PROFILES = {
|
|
|
553
562
|
'project',
|
|
554
563
|
'search',
|
|
555
564
|
'documents',
|
|
565
|
+
'canvas',
|
|
556
566
|
'web',
|
|
557
567
|
'factory_models',
|
|
558
568
|
],
|
|
@@ -608,6 +618,7 @@ export const TOOL_PROFILES = {
|
|
|
608
618
|
'dependencies',
|
|
609
619
|
'backlog_read',
|
|
610
620
|
'documents',
|
|
621
|
+
'canvas',
|
|
611
622
|
'plans',
|
|
612
623
|
'artifacts',
|
|
613
624
|
'anchors',
|
|
@@ -631,6 +642,7 @@ export const TOOL_PROFILES = {
|
|
|
631
642
|
'backlog_read',
|
|
632
643
|
'backlog_write',
|
|
633
644
|
'documents',
|
|
645
|
+
'canvas',
|
|
634
646
|
'plans',
|
|
635
647
|
'artifacts',
|
|
636
648
|
'anchors',
|
|
@@ -652,6 +664,7 @@ export const TOOL_PROFILES = {
|
|
|
652
664
|
'backlog_read',
|
|
653
665
|
'backlog_write',
|
|
654
666
|
'documents',
|
|
667
|
+
'canvas',
|
|
655
668
|
'artifacts',
|
|
656
669
|
'anchors',
|
|
657
670
|
'web',
|