@compilr-dev/sdk 0.2.1 → 0.2.2

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
@@ -59,5 +59,7 @@ export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getSt
59
59
  export { platformSkills, designSkill, sketchSkill, prdSkill, refineSkill, refineItemSkill, architectureSkill, sessionNotesSkill, buildSkill, scaffoldSkill, } from './skills/index.js';
60
60
  export { defineTool, createSuccessResult, createErrorResult, mergeHooks, createLoggingHooks, createClaudeProvider, createOpenAIProvider, createGeminiNativeProvider, createOllamaProvider, createTogetherProvider, createGroqProvider, createFireworksProvider, createPerplexityProvider, createOpenRouterProvider, createMockProvider, MockProvider, Agent, ContextManager, DEFAULT_CONTEXT_CONFIG, createTaskTool, createSuggestTool, defaultAgentTypes, TOOL_SETS, BUILTIN_GUARDRAILS, TOOL_NAMES, getDefaultShellManager, builtinSkills, AnchorManager, MCPManager, AgentError, ProviderError, ToolError, ToolTimeoutError, MaxIterationsError, AbortError, } from '@compilr-dev/agents';
61
61
  export type { Tool, HooksConfig, AgentEvent, Message, LLMProvider, AnchorInput, ToolExecutionResult, AgentRunResult, PermissionHandler, ToolPermission, AgentTypeConfig, GuardrailTriggeredHandler, BeforeLLMHookResult, BeforeToolHook, BeforeToolHookResult, AfterToolHook, AgentState, AgentConfig, SessionInfo, Anchor, AnchorScope, AnchorClearOptions, AnchorPriority, AnchorQueryOptions, FileAccessType, FileAccess, GuardrailResult, GuardrailContext, MCPClient, MCPToolDefinition, } from '@compilr-dev/agents';
62
+ export { DEFAULT_PERMISSION_RULES, findMatchingRule, permissionModeLabel, permissionLevelLabel, } from './permissions.js';
63
+ export type { PermissionRule, PermissionMode, PermissionLevel } from './permissions.js';
62
64
  export { readFileTool, writeFileTool, createBashTool, bashTool, bashOutputTool, killShellTool, grepTool, globTool, editTool, todoWriteTool, todoReadTool, createTodoTools, TodoStore, webFetchTool, suggestTool, } from '@compilr-dev/agents';
63
65
  export { gitStatusTool, gitDiffTool, gitLogTool, gitCommitTool, gitBranchTool, gitStashTool, gitBlameTool, gitFileHistoryTool, detectProjectTool, findProjectRootTool, runTestsTool, runLintTool, runBuildTool, runFormatTool, findDefinitionTool, findReferencesTool, findTodosTool, checkOutdatedTool, findVulnerabilitiesTool, analyzeTestCoverageTool, getFileStructureTool, getComplexityTool, allCodingTools, unifiedTools, } from '@compilr-dev/agents-coding';
package/dist/index.js CHANGED
@@ -153,6 +153,10 @@ MCPManager,
153
153
  // Error types
154
154
  AgentError, ProviderError, ToolError, ToolTimeoutError, MaxIterationsError, AbortError, } from '@compilr-dev/agents';
155
155
  // =============================================================================
156
+ // Shared Permission Defaults & Utilities
157
+ // =============================================================================
158
+ export { DEFAULT_PERMISSION_RULES, findMatchingRule, permissionModeLabel, permissionLevelLabel, } from './permissions.js';
159
+ // =============================================================================
156
160
  // Individual Tool Re-exports (for consumers that build custom tool registries)
157
161
  // =============================================================================
158
162
  // Base tools from @compilr-dev/agents
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Shared permission types and defaults for CLI and Desktop.
3
+ *
4
+ * Both consumers define the same default rules and modes. This module
5
+ * provides a single source of truth so they stay in sync.
6
+ */
7
+ import type { ToolPermission } from '@compilr-dev/agents';
8
+ /**
9
+ * Permission level for a tool.
10
+ * Re-exported from agents for convenience.
11
+ */
12
+ export type PermissionLevel = 'always' | 'session' | 'once' | 'deny';
13
+ /**
14
+ * Extended permission rule with UI metadata.
15
+ * Extends ToolPermission with an isDefault flag so UIs can distinguish
16
+ * built-in rules from user-customized ones (default rules cannot be deleted).
17
+ */
18
+ export interface PermissionRule extends ToolPermission {
19
+ /** True for built-in rules (cannot be deleted, only level can be changed) */
20
+ isDefault?: boolean;
21
+ }
22
+ /**
23
+ * Global permission mode controlling how the permission system behaves.
24
+ * - 'normal': Use rule-based checking (check each tool's configured level)
25
+ * - 'plan': Always prompt before any tool execution (ignores rules)
26
+ * - 'auto-accept': Allow everything without prompting
27
+ */
28
+ export type PermissionMode = 'normal' | 'plan' | 'auto-accept';
29
+ /**
30
+ * Default permission rules shared between CLI and Desktop.
31
+ *
32
+ * The model is "allow by default, restrict dangerous tools":
33
+ * - Read-only tools (read_file, glob, grep) → always allowed
34
+ * - Write/execute tools (bash, write_file, edit) → ask once per invocation
35
+ * - Git mutating tools (git_commit, git_branch) → ask once
36
+ * - Runner tools (run_tests, run_lint) → ask once
37
+ */
38
+ export declare const DEFAULT_PERMISSION_RULES: PermissionRule[];
39
+ /**
40
+ * Find the matching permission rule for a tool name.
41
+ * Checks exact match first, then wildcard patterns (e.g., git_* matches git_commit).
42
+ */
43
+ export declare function findMatchingRule(rules: PermissionRule[], toolName: string): PermissionRule | null;
44
+ /**
45
+ * Display label for a permission mode.
46
+ */
47
+ export declare function permissionModeLabel(mode: PermissionMode): string;
48
+ /**
49
+ * Display label for a permission level.
50
+ */
51
+ export declare function permissionLevelLabel(level: PermissionLevel): string;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Shared permission types and defaults for CLI and Desktop.
3
+ *
4
+ * Both consumers define the same default rules and modes. This module
5
+ * provides a single source of truth so they stay in sync.
6
+ */
7
+ // =============================================================================
8
+ // Default Rules
9
+ // =============================================================================
10
+ /**
11
+ * Default permission rules shared between CLI and Desktop.
12
+ *
13
+ * The model is "allow by default, restrict dangerous tools":
14
+ * - Read-only tools (read_file, glob, grep) → always allowed
15
+ * - Write/execute tools (bash, write_file, edit) → ask once per invocation
16
+ * - Git mutating tools (git_commit, git_branch) → ask once
17
+ * - Runner tools (run_tests, run_lint) → ask once
18
+ */
19
+ export const DEFAULT_PERMISSION_RULES = [
20
+ { toolName: 'bash', level: 'once', description: 'Execute shell commands', isDefault: true },
21
+ { toolName: 'write_file', level: 'once', description: 'Write/create files', isDefault: true },
22
+ { toolName: 'edit', level: 'once', description: 'Edit file contents', isDefault: true },
23
+ { toolName: 'git_commit', level: 'once', description: 'Create git commits', isDefault: true },
24
+ { toolName: 'git_branch', level: 'once', description: 'Create/delete branches', isDefault: true },
25
+ { toolName: 'run_tests', level: 'once', description: 'Run test suite', isDefault: true },
26
+ {
27
+ toolName: 'run_lint',
28
+ level: 'once',
29
+ description: 'Run linter (may auto-fix)',
30
+ isDefault: true,
31
+ },
32
+ { toolName: 'read_file', level: 'always', description: 'Read files', isDefault: true },
33
+ { toolName: 'glob', level: 'always', description: 'Find files by pattern', isDefault: true },
34
+ { toolName: 'grep', level: 'always', description: 'Search file contents', isDefault: true },
35
+ ];
36
+ // =============================================================================
37
+ // Utilities
38
+ // =============================================================================
39
+ /**
40
+ * Find the matching permission rule for a tool name.
41
+ * Checks exact match first, then wildcard patterns (e.g., git_* matches git_commit).
42
+ */
43
+ export function findMatchingRule(rules, toolName) {
44
+ // Exact match first
45
+ const exact = rules.find((r) => r.toolName === toolName);
46
+ if (exact)
47
+ return exact;
48
+ // Wildcard match (e.g., git_* → /^git_.*$/)
49
+ for (const rule of rules) {
50
+ if (rule.toolName.includes('*')) {
51
+ const pattern = new RegExp('^' + rule.toolName.replace(/\*/g, '.*') + '$');
52
+ if (pattern.test(toolName))
53
+ return rule;
54
+ }
55
+ }
56
+ return null;
57
+ }
58
+ /**
59
+ * Display label for a permission mode.
60
+ */
61
+ export function permissionModeLabel(mode) {
62
+ switch (mode) {
63
+ case 'normal':
64
+ return 'Normal';
65
+ case 'plan':
66
+ return 'Plan (ask for everything)';
67
+ case 'auto-accept':
68
+ return 'Auto-accept (no prompts)';
69
+ }
70
+ }
71
+ /**
72
+ * Display label for a permission level.
73
+ */
74
+ export function permissionLevelLabel(level) {
75
+ switch (level) {
76
+ case 'always':
77
+ return 'Always allow';
78
+ case 'session':
79
+ return 'Ask once per session';
80
+ case 'once':
81
+ return 'Ask every time';
82
+ case 'deny':
83
+ return 'Always deny';
84
+ }
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",