@compilr-dev/sdk 0.9.9 → 0.9.11

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/index.d.ts CHANGED
@@ -36,10 +36,10 @@
36
36
  export { createCompilrAgent } from './agent.js';
37
37
  export type { CompilrAgentConfig, CompilrAgent, RunOptions, RunResult, ToolCallRecord, ToolConfig, UsageInfo, ProviderType, PermissionCallback, GuardrailConfig, ContextConfig, CapabilitiesConfig, } from './config.js';
38
38
  export { AgentTeam, TeamAgent, SharedContextManager, ArtifactStore, DelegationTracker, ContextResolver, } from './team/index.js';
39
- export type { AgentTeamConfig, TeamAgentConfig, ITeamPersistence, IArtifactStorage, ISessionRegistry, CustomAgentDefinition, ToolConfig as TeamToolConfig, ToolTier, ToolGroup, ProfileInfo, } from './team/index.js';
39
+ export type { AgentTeamConfig, TeamAgentConfig, ITeamPersistence, IArtifactStorage, ISessionRegistry, CustomAgentDefinition, AgentTemplate, ToolConfig as TeamToolConfig, ToolTier, ToolGroup, ProfileInfo, } from './team/index.js';
40
40
  export type { AgentRole, RoleMetadata, ToolProfile, MascotExpression, BackgroundSessionInfo, SerializedTeam, SerializedTeamAgent, TeamMetadata, TeamEvent, TeamEventType, TeamEventHandler, Artifact, ArtifactType as TeamArtifactType, ArtifactSummary as TeamArtifactSummary, CreateArtifactOptions, UpdateArtifactOptions, SerializedArtifact, SharedContext, SharedProjectInfo, SharedTeamInfo, TeamRosterEntry, TeamActivity, TeamActivityType, SharedDecision, TokenBudget, SerializedSharedContext, ParsedMention, ParsedInput, ResolvedMention, ResolveOptions, ResolutionSource, Delegation, DelegationStatus, DelegationResult, CompletionEvent, CreateDelegationOptions, DelegationStats, DelegationTrackerEvents, SkillToolRequirement, } from './team/index.js';
41
41
  export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS, TOOL_GROUPS, TOOL_PROFILES, PROFILE_INFO, SKILL_REQUIREMENTS, CUSTOM_MASCOTS, } from './team/index.js';
42
- export { getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAwarenessPrompt, generateCoordinatorGuidance, generateSpecialistGuidance, createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile, assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, buildContextMap, findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, suggestOwner, suggestOwners, matchesAgentExpertise, wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, resolveAgentIdCollision, setActiveSharedContext, getActiveSharedContext, recordTeamActivity, getDefinedSkillNames, getSkillRequirements, checkSkillCompatibility, getCompatibleSkills, getAllRequiredTools, getSkillsByCategory, } from './team/index.js';
42
+ export { getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAwarenessPrompt, generateCoordinatorGuidance, generateSpecialistGuidance, createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile, assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, listTemplates, getTemplate, saveTemplate, updateTemplate, deleteTemplate, createAgentFromTemplate, parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, buildContextMap, findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, suggestOwner, suggestOwners, matchesAgentExpertise, wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, resolveAgentIdCollision, setActiveSharedContext, getActiveSharedContext, recordTeamActivity, getDefinedSkillNames, getSkillRequirements, checkSkillCompatibility, getCompatibleSkills, getAllRequiredTools, getSkillsByCategory, } from './team/index.js';
43
43
  export { codingPreset, readOnlyPreset, resolvePreset } from './presets/index.js';
44
44
  export type { Preset } from './presets/index.js';
45
45
  export type { AnyTool } from './presets/types.js';
package/dist/index.js CHANGED
@@ -52,6 +52,8 @@ getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAware
52
52
  createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile,
53
53
  // Custom agents
54
54
  assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition,
55
+ // Agent templates
56
+ listTemplates, getTemplate, saveTemplate, updateTemplate, deleteTemplate, createAgentFromTemplate,
55
57
  // Mention parsing
56
58
  parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, buildContextMap,
57
59
  // Agent selection
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Agent Templates — Reusable custom agent configurations.
3
+ *
4
+ * Stored globally in ~/.compilr-dev/agent-templates.json (not per-project).
5
+ * Templates include all agent config except ID and mascot (assigned at creation).
6
+ */
7
+ import type { CustomAgentDefinition } from './custom-agents.js';
8
+ export interface AgentTemplate {
9
+ /** Unique template ID (auto-generated) */
10
+ id: string;
11
+ /** Template name (user-facing) */
12
+ name: string;
13
+ /** Optional description */
14
+ description?: string;
15
+ /** When created */
16
+ createdAt: string;
17
+ /** When last updated */
18
+ updatedAt: string;
19
+ displayName: string;
20
+ specialty: string;
21
+ personality?: string;
22
+ systemPromptAddition?: string;
23
+ toolProfile?: string;
24
+ enabledSkills?: string[];
25
+ modelTier?: string;
26
+ }
27
+ /** List all saved templates */
28
+ export declare function listTemplates(): AgentTemplate[];
29
+ /** Get a template by ID */
30
+ export declare function getTemplate(id: string): AgentTemplate | null;
31
+ /** Save a new template from a custom agent definition */
32
+ export declare function saveTemplate(name: string, agent: CustomAgentDefinition, description?: string): AgentTemplate;
33
+ /** Update an existing template */
34
+ export declare function updateTemplate(id: string, updates: Partial<Omit<AgentTemplate, 'id' | 'createdAt'>>): AgentTemplate | null;
35
+ /** Delete a template */
36
+ export declare function deleteTemplate(id: string): boolean;
37
+ /** Create a CustomAgentDefinition from a template */
38
+ export declare function createAgentFromTemplate(template: AgentTemplate, agentId: string, existingAgents: CustomAgentDefinition[]): CustomAgentDefinition;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Agent Templates — Reusable custom agent configurations.
3
+ *
4
+ * Stored globally in ~/.compilr-dev/agent-templates.json (not per-project).
5
+ * Templates include all agent config except ID and mascot (assigned at creation).
6
+ */
7
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
8
+ import { join } from 'node:path';
9
+ import { homedir } from 'node:os';
10
+ import { assignMascot } from './custom-agents.js';
11
+ // =============================================================================
12
+ // Storage
13
+ // =============================================================================
14
+ function getTemplatesPath() {
15
+ return join(homedir(), '.compilr-dev', 'agent-templates.json');
16
+ }
17
+ function readTemplates() {
18
+ const path = getTemplatesPath();
19
+ if (!existsSync(path))
20
+ return [];
21
+ try {
22
+ return JSON.parse(readFileSync(path, 'utf-8'));
23
+ }
24
+ catch {
25
+ return [];
26
+ }
27
+ }
28
+ function writeTemplates(templates) {
29
+ const dir = join(homedir(), '.compilr-dev');
30
+ if (!existsSync(dir))
31
+ mkdirSync(dir, { recursive: true });
32
+ writeFileSync(getTemplatesPath(), JSON.stringify(templates, null, 2));
33
+ }
34
+ function generateId() {
35
+ return `tmpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
36
+ }
37
+ // =============================================================================
38
+ // CRUD Operations
39
+ // =============================================================================
40
+ /** List all saved templates */
41
+ export function listTemplates() {
42
+ return readTemplates();
43
+ }
44
+ /** Get a template by ID */
45
+ export function getTemplate(id) {
46
+ return readTemplates().find((t) => t.id === id) ?? null;
47
+ }
48
+ /** Save a new template from a custom agent definition */
49
+ export function saveTemplate(name, agent, description) {
50
+ const templates = readTemplates();
51
+ const now = new Date().toISOString();
52
+ const template = {
53
+ id: generateId(),
54
+ name,
55
+ description,
56
+ createdAt: now,
57
+ updatedAt: now,
58
+ displayName: agent.displayName,
59
+ specialty: agent.specialty,
60
+ personality: agent.personality,
61
+ systemPromptAddition: agent.systemPromptAddition,
62
+ toolProfile: agent.toolConfig?.profile,
63
+ enabledSkills: agent.enabledSkills,
64
+ modelTier: agent.modelTier,
65
+ };
66
+ templates.push(template);
67
+ writeTemplates(templates);
68
+ return template;
69
+ }
70
+ /** Update an existing template */
71
+ export function updateTemplate(id, updates) {
72
+ const templates = readTemplates();
73
+ const idx = templates.findIndex((t) => t.id === id);
74
+ if (idx < 0)
75
+ return null;
76
+ templates[idx] = {
77
+ ...templates[idx],
78
+ ...updates,
79
+ updatedAt: new Date().toISOString(),
80
+ };
81
+ writeTemplates(templates);
82
+ return templates[idx];
83
+ }
84
+ /** Delete a template */
85
+ export function deleteTemplate(id) {
86
+ const templates = readTemplates();
87
+ const filtered = templates.filter((t) => t.id !== id);
88
+ if (filtered.length === templates.length)
89
+ return false;
90
+ writeTemplates(filtered);
91
+ return true;
92
+ }
93
+ /** Create a CustomAgentDefinition from a template */
94
+ export function createAgentFromTemplate(template, agentId, existingAgents) {
95
+ return {
96
+ id: agentId,
97
+ displayName: template.displayName,
98
+ specialty: template.specialty,
99
+ personality: template.personality,
100
+ systemPromptAddition: template.systemPromptAddition,
101
+ mascot: assignMascot(existingAgents),
102
+ createdAt: new Date().toISOString(),
103
+ toolConfig: template.toolProfile ? { profile: template.toolProfile } : undefined,
104
+ enabledSkills: template.enabledSkills,
105
+ modelTier: template.modelTier,
106
+ };
107
+ }
@@ -19,6 +19,8 @@ export interface CustomAgentDefinition {
19
19
  toolConfig?: ToolConfig;
20
20
  enabledSkills?: string[];
21
21
  modelTier?: ModelTier;
22
+ /** Custom instructions appended to the agent's system prompt (max 2000 chars) */
23
+ systemPromptAddition?: string;
22
24
  }
23
25
  export type { ToolConfig, ToolProfile };
24
26
  /**
@@ -65,4 +67,4 @@ export declare function isAgentIdTaken(id: string, existingCustomAgents: CustomA
65
67
  /**
66
68
  * Create a new CustomAgentDefinition with auto-assigned mascot.
67
69
  */
68
- export declare function createCustomAgentDefinition(id: string, displayName: string, specialty: string, personality: string | undefined, existingAgents: CustomAgentDefinition[], toolConfig?: ToolConfig, enabledSkills?: string[], modelTier?: ModelTier): CustomAgentDefinition;
70
+ export declare function createCustomAgentDefinition(id: string, displayName: string, specialty: string, personality: string | undefined, existingAgents: CustomAgentDefinition[], toolConfig?: ToolConfig, enabledSkills?: string[], modelTier?: ModelTier, systemPromptAddition?: string): CustomAgentDefinition;
@@ -62,6 +62,15 @@ export function generateCustomAgentSystemPrompt(agent) {
62
62
  }
63
63
  lines.push('');
64
64
  lines.push('Focus on your area of expertise. When questions fall outside your specialty, suggest which team member might be better suited to help.');
65
+ // Append custom instructions if provided
66
+ if (agent.systemPromptAddition?.trim()) {
67
+ lines.push('');
68
+ lines.push('---');
69
+ lines.push('');
70
+ lines.push('## Custom Instructions');
71
+ lines.push('');
72
+ lines.push(agent.systemPromptAddition.trim());
73
+ }
65
74
  // Add tool awareness if agent has tool restrictions
66
75
  const toolConfig = agent.toolConfig ?? createDefaultToolConfig();
67
76
  if (toolConfig.profile !== 'full') {
@@ -135,7 +144,7 @@ export function isAgentIdTaken(id, existingCustomAgents, teamAgentIds, predefine
135
144
  /**
136
145
  * Create a new CustomAgentDefinition with auto-assigned mascot.
137
146
  */
138
- export function createCustomAgentDefinition(id, displayName, specialty, personality, existingAgents, toolConfig, enabledSkills, modelTier) {
147
+ export function createCustomAgentDefinition(id, displayName, specialty, personality, existingAgents, toolConfig, enabledSkills, modelTier, systemPromptAddition) {
139
148
  return {
140
149
  id,
141
150
  displayName,
@@ -146,5 +155,6 @@ export function createCustomAgentDefinition(id, displayName, specialty, personal
146
155
  toolConfig: toolConfig ?? createDefaultToolConfig(),
147
156
  enabledSkills: enabledSkills ?? [], // Empty = all skills
148
157
  modelTier: modelTier ?? 'balanced', // Default tier
158
+ systemPromptAddition: systemPromptAddition?.trim() || undefined,
149
159
  };
150
160
  }
@@ -18,6 +18,8 @@ export type { ToolConfig, ToolTier, ToolGroup, ProfileInfo } from './tool-config
18
18
  export { createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile, } from './tool-config.js';
19
19
  export type { CustomAgentDefinition } from './custom-agents.js';
20
20
  export { CUSTOM_MASCOTS, assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, } from './custom-agents.js';
21
+ export type { AgentTemplate } from './agent-templates.js';
22
+ export { listTemplates, getTemplate, saveTemplate, updateTemplate, deleteTemplate, createAgentFromTemplate, } from './agent-templates.js';
21
23
  export type { ITeamPersistence, IArtifactStorage, ISessionRegistry } from './interfaces.js';
22
24
  export type { ParsedMention, ParsedInput } from './mention-parser.js';
23
25
  export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, } from './mention-parser.js';
@@ -14,6 +14,7 @@ export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from './types.js';
14
14
  export { TOOL_GROUPS, TOOL_PROFILES, PROFILE_INFO, getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAwarenessPrompt, generateCoordinatorGuidance, generateSpecialistGuidance, } from './tool-config.js';
15
15
  export { createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile, } from './tool-config.js';
16
16
  export { CUSTOM_MASCOTS, assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, } from './custom-agents.js';
17
+ export { listTemplates, getTemplate, saveTemplate, updateTemplate, deleteTemplate, createAgentFromTemplate, } from './agent-templates.js';
17
18
  export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, } from './mention-parser.js';
18
19
  export { ContextResolver, buildContextMap } from './context-resolver.js';
19
20
  // Agent selection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.9.9",
3
+ "version": "0.9.11",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",