@compilr-dev/sdk 0.2.0 → 0.2.1

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 CHANGED
@@ -29,17 +29,27 @@ function toRunResult(raw) {
29
29
  };
30
30
  }
31
31
  /**
32
- * Build permission manager options from config
32
+ * Build permission manager options from config.
33
+ *
34
+ * When a PermissionCallback is provided:
35
+ * - defaultLevel is 'always' (tools auto-allowed unless rules say otherwise)
36
+ * - includeDefaults is true (agents library's built-in rules for dangerous tools)
37
+ * - Custom rules can be passed via permissionRules
38
+ *
39
+ * This matches the CLI pattern: everything allowed by default, only dangerous
40
+ * tools (bash, write_file, edit, etc.) require user approval.
33
41
  */
34
- function buildPermissions(permissions, presetDefault) {
42
+ function buildPermissions(permissions, presetDefault, permissionRules, includeDefaultRules) {
35
43
  const mode = permissions ?? presetDefault ?? 'auto';
36
44
  if (mode === 'read-only') {
37
45
  return { defaultLevel: 'deny' };
38
46
  }
39
47
  if (typeof mode === 'function') {
40
48
  return {
41
- defaultLevel: 'once',
49
+ defaultLevel: 'always',
42
50
  onPermissionRequest: mode,
51
+ rules: permissionRules,
52
+ includeDefaults: includeDefaultRules ?? true,
43
53
  };
44
54
  }
45
55
  // 'auto' — allow all tools
@@ -102,7 +112,7 @@ class CompilrAgentImpl {
102
112
  });
103
113
  }
104
114
  // Build agent config
105
- const permissionsConfig = buildPermissions(config?.permissions, preset.defaultPermissions);
115
+ const permissionsConfig = buildPermissions(config?.permissions, preset.defaultPermissions, config?.permissionRules, config?.includeDefaultRules);
106
116
  const guardrailsConfig = buildGuardrails(config?.guardrails);
107
117
  this.agent = new Agent({
108
118
  provider,
@@ -114,6 +124,8 @@ class CompilrAgentImpl {
114
124
  permissions: {
115
125
  defaultLevel: permissionsConfig.defaultLevel,
116
126
  onPermissionRequest: permissionsConfig.onPermissionRequest,
127
+ rules: permissionsConfig.rules,
128
+ includeDefaults: permissionsConfig.includeDefaults,
117
129
  },
118
130
  guardrails: {
119
131
  enabled: guardrailsConfig.enabled,
package/dist/config.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * SDK configuration types
3
3
  */
4
- import type { LLMProvider, Message, Tool, HooksConfig, AnchorInput, AgentEvent, ToolExecutionResult } from '@compilr-dev/agents';
4
+ import type { LLMProvider, Message, Tool, ToolPermission, HooksConfig, AnchorInput, AgentEvent, ToolExecutionResult } from '@compilr-dev/agents';
5
5
  import type { Preset } from './presets/types.js';
6
6
  /**
7
7
  * Supported provider types for auto-detection
@@ -128,6 +128,17 @@ export interface CompilrAgentConfig {
128
128
  tools?: ToolConfig;
129
129
  /** Permission mode. Default: 'auto' */
130
130
  permissions?: 'auto' | 'read-only' | PermissionCallback;
131
+ /**
132
+ * Tool-specific permission rules (e.g., bash='once', read_file='always').
133
+ * When omitted with a PermissionCallback, the agents library's built-in
134
+ * defaults are used (includeDefaults: true).
135
+ */
136
+ permissionRules?: ToolPermission[];
137
+ /**
138
+ * Whether to include the agents library's built-in default permission rules.
139
+ * Default: true when a PermissionCallback is provided, false otherwise.
140
+ */
141
+ includeDefaultRules?: boolean;
131
142
  /** Guardrail configuration. Default: true */
132
143
  guardrails?: boolean | GuardrailConfig;
133
144
  /** Lifecycle hooks */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",