@compilr-dev/sdk 0.1.0
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/LICENSE +21 -0
- package/dist/agent.d.ts +8 -0
- package/dist/agent.js +220 -0
- package/dist/config.d.ts +227 -0
- package/dist/config.js +4 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +99 -0
- package/dist/models/index.d.ts +7 -0
- package/dist/models/index.js +11 -0
- package/dist/models/model-registry.d.ts +118 -0
- package/dist/models/model-registry.js +621 -0
- package/dist/models/model-tiers.d.ts +36 -0
- package/dist/models/model-tiers.js +105 -0
- package/dist/models/providers.d.ts +90 -0
- package/dist/models/providers.js +295 -0
- package/dist/models/types.d.ts +28 -0
- package/dist/models/types.js +30 -0
- package/dist/models.d.ts +21 -0
- package/dist/models.js +73 -0
- package/dist/presets/coding.d.ts +21 -0
- package/dist/presets/coding.js +61 -0
- package/dist/presets/index.d.ts +11 -0
- package/dist/presets/index.js +32 -0
- package/dist/presets/read-only.d.ts +8 -0
- package/dist/presets/read-only.js +44 -0
- package/dist/presets/types.d.ts +30 -0
- package/dist/presets/types.js +4 -0
- package/dist/provider.d.ts +28 -0
- package/dist/provider.js +88 -0
- package/dist/team.d.ts +10 -0
- package/dist/team.js +168 -0
- package/dist/tools.d.ts +18 -0
- package/dist/tools.js +95 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Carmelo Scozzola
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CompilrAgent — high-level wrapper around @compilr-dev/agents Agent
|
|
3
|
+
*/
|
|
4
|
+
import type { CompilrAgentConfig, CompilrAgent as ICompilrAgent } from './config.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create a new CompilrAgent
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCompilrAgent(config?: CompilrAgentConfig): ICompilrAgent;
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CompilrAgent — high-level wrapper around @compilr-dev/agents Agent
|
|
3
|
+
*/
|
|
4
|
+
import { Agent, ContextManager, } from '@compilr-dev/agents';
|
|
5
|
+
import { resolveProvider } from './provider.js';
|
|
6
|
+
import { resolvePreset } from './presets/index.js';
|
|
7
|
+
import { assembleTools, deduplicateTools } from './tools.js';
|
|
8
|
+
import { getContextWindow } from './models.js';
|
|
9
|
+
/**
|
|
10
|
+
* Convert an AgentRunResult to our simplified RunResult
|
|
11
|
+
*/
|
|
12
|
+
function toRunResult(raw) {
|
|
13
|
+
const usage = {
|
|
14
|
+
inputTokens: 0,
|
|
15
|
+
outputTokens: 0,
|
|
16
|
+
totalTokens: 0,
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
response: raw.response,
|
|
20
|
+
iterations: raw.iterations,
|
|
21
|
+
toolCalls: raw.toolCalls.map((tc) => ({
|
|
22
|
+
name: tc.name,
|
|
23
|
+
input: tc.input,
|
|
24
|
+
result: tc.result,
|
|
25
|
+
})),
|
|
26
|
+
aborted: raw.aborted,
|
|
27
|
+
usage,
|
|
28
|
+
messages: raw.messages,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build permission manager options from config
|
|
33
|
+
*/
|
|
34
|
+
function buildPermissions(permissions, presetDefault) {
|
|
35
|
+
const mode = permissions ?? presetDefault ?? 'auto';
|
|
36
|
+
if (mode === 'read-only') {
|
|
37
|
+
return { defaultLevel: 'deny' };
|
|
38
|
+
}
|
|
39
|
+
if (typeof mode === 'function') {
|
|
40
|
+
return {
|
|
41
|
+
defaultLevel: 'once',
|
|
42
|
+
onPermissionRequest: mode,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// 'auto' — allow all tools
|
|
46
|
+
return { defaultLevel: 'always' };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build guardrail options from config
|
|
50
|
+
*/
|
|
51
|
+
function buildGuardrails(guardrails) {
|
|
52
|
+
if (guardrails === false) {
|
|
53
|
+
return { enabled: false };
|
|
54
|
+
}
|
|
55
|
+
if (guardrails === true || guardrails === undefined) {
|
|
56
|
+
return { enabled: true, includeDefaults: true };
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
enabled: true,
|
|
60
|
+
includeDefaults: guardrails.includeDefaults ?? true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* CompilrAgent implementation
|
|
65
|
+
*/
|
|
66
|
+
class CompilrAgentImpl {
|
|
67
|
+
agent;
|
|
68
|
+
abortController;
|
|
69
|
+
totalUsage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
70
|
+
constructor(config) {
|
|
71
|
+
this.abortController = new AbortController();
|
|
72
|
+
// Resolve provider
|
|
73
|
+
const provider = resolveProvider({
|
|
74
|
+
provider: config?.provider,
|
|
75
|
+
model: config?.model,
|
|
76
|
+
apiKey: config?.apiKey,
|
|
77
|
+
});
|
|
78
|
+
// Resolve preset
|
|
79
|
+
const preset = resolvePreset(config?.preset ?? 'coding');
|
|
80
|
+
// Build system prompt
|
|
81
|
+
let systemPrompt;
|
|
82
|
+
if (config?.systemPrompt === false) {
|
|
83
|
+
systemPrompt = undefined;
|
|
84
|
+
}
|
|
85
|
+
else if (config?.systemPrompt) {
|
|
86
|
+
systemPrompt = config.systemPrompt;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
systemPrompt = preset.systemPrompt;
|
|
90
|
+
}
|
|
91
|
+
// Assemble tools
|
|
92
|
+
const tools = deduplicateTools(assembleTools(preset, config?.tools));
|
|
93
|
+
// Build context manager if configured
|
|
94
|
+
let contextManager;
|
|
95
|
+
if (config?.context) {
|
|
96
|
+
const contextLimit = config.context.contextLimit ?? getContextWindow(config.model);
|
|
97
|
+
contextManager = new ContextManager({
|
|
98
|
+
provider,
|
|
99
|
+
config: {
|
|
100
|
+
maxContextTokens: contextLimit,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// Build agent config
|
|
105
|
+
const permissionsConfig = buildPermissions(config?.permissions, preset.defaultPermissions);
|
|
106
|
+
const guardrailsConfig = buildGuardrails(config?.guardrails);
|
|
107
|
+
this.agent = new Agent({
|
|
108
|
+
provider,
|
|
109
|
+
systemPrompt,
|
|
110
|
+
maxIterations: config?.maxIterations ?? 50,
|
|
111
|
+
contextManager,
|
|
112
|
+
autoContextManagement: contextManager !== undefined,
|
|
113
|
+
hooks: config?.hooks,
|
|
114
|
+
permissions: {
|
|
115
|
+
defaultLevel: permissionsConfig.defaultLevel,
|
|
116
|
+
onPermissionRequest: permissionsConfig.onPermissionRequest,
|
|
117
|
+
},
|
|
118
|
+
guardrails: {
|
|
119
|
+
enabled: guardrailsConfig.enabled,
|
|
120
|
+
includeDefaults: guardrailsConfig.includeDefaults,
|
|
121
|
+
},
|
|
122
|
+
onEvent: (event) => {
|
|
123
|
+
// Track usage from events
|
|
124
|
+
if (event.type === 'usage_recorded') {
|
|
125
|
+
this.totalUsage.inputTokens += event.tokens.inputTokens;
|
|
126
|
+
this.totalUsage.outputTokens += event.tokens.outputTokens;
|
|
127
|
+
this.totalUsage.totalTokens += event.tokens.inputTokens + event.tokens.outputTokens;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
// Register tools (cast AnyTool[] → Tool[] for the Agent API)
|
|
132
|
+
this.agent.registerTools(tools);
|
|
133
|
+
}
|
|
134
|
+
async run(message, options) {
|
|
135
|
+
const result = await this.agent.run(message, {
|
|
136
|
+
signal: options?.signal ?? this.abortController.signal,
|
|
137
|
+
maxIterations: options?.maxIterations,
|
|
138
|
+
onEvent: options?.onEvent,
|
|
139
|
+
toolFilter: options?.toolFilter,
|
|
140
|
+
});
|
|
141
|
+
return toRunResult(result);
|
|
142
|
+
}
|
|
143
|
+
async *stream(message, options) {
|
|
144
|
+
const events = [];
|
|
145
|
+
let notifyNewEvent;
|
|
146
|
+
const finished = { value: false };
|
|
147
|
+
const onEvent = (event) => {
|
|
148
|
+
events.push(event);
|
|
149
|
+
options?.onEvent?.(event);
|
|
150
|
+
notifyNewEvent?.();
|
|
151
|
+
};
|
|
152
|
+
const markDone = () => {
|
|
153
|
+
finished.value = true;
|
|
154
|
+
notifyNewEvent?.();
|
|
155
|
+
};
|
|
156
|
+
// Run in background, collecting events
|
|
157
|
+
const runPromise = this.agent
|
|
158
|
+
.run(message, {
|
|
159
|
+
signal: options?.signal ?? this.abortController.signal,
|
|
160
|
+
maxIterations: options?.maxIterations,
|
|
161
|
+
onEvent,
|
|
162
|
+
toolFilter: options?.toolFilter,
|
|
163
|
+
})
|
|
164
|
+
.then(markDone)
|
|
165
|
+
.catch(markDone);
|
|
166
|
+
// Yield events as they arrive
|
|
167
|
+
for (;;) {
|
|
168
|
+
if (events.length > 0) {
|
|
169
|
+
const event = events.shift();
|
|
170
|
+
if (event) {
|
|
171
|
+
yield event;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else if (finished.value) {
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
await new Promise((r) => {
|
|
179
|
+
notifyNewEvent = r;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
await runPromise;
|
|
184
|
+
}
|
|
185
|
+
async chat(message, options) {
|
|
186
|
+
return this.run(message, options);
|
|
187
|
+
}
|
|
188
|
+
addTool(tool) {
|
|
189
|
+
this.agent.registerTool(tool);
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
addAnchor(input) {
|
|
193
|
+
this.agent.addAnchor(input);
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
getHistory() {
|
|
197
|
+
return this.agent.getHistory();
|
|
198
|
+
}
|
|
199
|
+
clearHistory() {
|
|
200
|
+
this.agent.clearHistory();
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
getUsage() {
|
|
204
|
+
return { ...this.totalUsage };
|
|
205
|
+
}
|
|
206
|
+
unwrap() {
|
|
207
|
+
return this.agent;
|
|
208
|
+
}
|
|
209
|
+
abort() {
|
|
210
|
+
this.abortController.abort();
|
|
211
|
+
// Create a new controller for future runs
|
|
212
|
+
this.abortController = new AbortController();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Create a new CompilrAgent
|
|
217
|
+
*/
|
|
218
|
+
export function createCompilrAgent(config) {
|
|
219
|
+
return new CompilrAgentImpl(config);
|
|
220
|
+
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK configuration types
|
|
3
|
+
*/
|
|
4
|
+
import type { LLMProvider, Message, Tool, HooksConfig, AnchorInput, AgentEvent, ToolExecutionResult } from '@compilr-dev/agents';
|
|
5
|
+
import type { Preset } from './presets/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Supported provider types for auto-detection
|
|
8
|
+
*/
|
|
9
|
+
export type ProviderType = 'claude' | 'openai' | 'gemini' | 'ollama' | 'together' | 'groq' | 'fireworks' | 'perplexity' | 'openrouter' | 'custom';
|
|
10
|
+
/**
|
|
11
|
+
* Tool configuration for controlling which tools are available
|
|
12
|
+
*/
|
|
13
|
+
export interface ToolConfig {
|
|
14
|
+
/** Include coding tools (git, runners, analysis). Default: true for coding preset */
|
|
15
|
+
coding?: boolean;
|
|
16
|
+
/** Include file tools (read, write, edit, glob, grep). Default: true */
|
|
17
|
+
files?: boolean;
|
|
18
|
+
/** Include shell tools (bash). Default: true for coding preset */
|
|
19
|
+
shell?: boolean;
|
|
20
|
+
/** Include web tools (web_fetch). Default: false */
|
|
21
|
+
web?: boolean;
|
|
22
|
+
/** Allowlist of tool names (overrides flags above) */
|
|
23
|
+
filter?: string[];
|
|
24
|
+
/** Additional custom tools (always included) */
|
|
25
|
+
custom?: Tool[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Permission callback for tool execution approval
|
|
29
|
+
*/
|
|
30
|
+
export type PermissionCallback = (request: {
|
|
31
|
+
toolName: string;
|
|
32
|
+
input: Record<string, unknown>;
|
|
33
|
+
}) => Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Guardrail configuration
|
|
36
|
+
*/
|
|
37
|
+
export interface GuardrailConfig {
|
|
38
|
+
/** Include built-in guardrails. Default: true */
|
|
39
|
+
includeDefaults?: boolean;
|
|
40
|
+
/** Custom guardrail patterns */
|
|
41
|
+
custom?: Array<{
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
patterns: RegExp[];
|
|
45
|
+
action: 'warn' | 'confirm' | 'block';
|
|
46
|
+
message: string;
|
|
47
|
+
scope?: string[];
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Context management configuration
|
|
52
|
+
*/
|
|
53
|
+
export interface ContextConfig {
|
|
54
|
+
/** Context window limit in tokens. Auto-detected from model if omitted. */
|
|
55
|
+
contextLimit?: number;
|
|
56
|
+
/** Threshold (0-1) to trigger compaction. Default: 0.5 */
|
|
57
|
+
compactionThreshold?: number;
|
|
58
|
+
/** Threshold (0-1) to trigger emergency summarization. Default: 0.9 */
|
|
59
|
+
summarizationThreshold?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Usage information for the agent
|
|
63
|
+
*/
|
|
64
|
+
export interface UsageInfo {
|
|
65
|
+
inputTokens: number;
|
|
66
|
+
outputTokens: number;
|
|
67
|
+
totalTokens: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Result of a single agent run
|
|
71
|
+
*/
|
|
72
|
+
export interface RunResult {
|
|
73
|
+
/** Final text response from the agent */
|
|
74
|
+
response: string;
|
|
75
|
+
/** Number of iterations (tool use loops) executed */
|
|
76
|
+
iterations: number;
|
|
77
|
+
/** Tool calls made during execution */
|
|
78
|
+
toolCalls: ToolCallRecord[];
|
|
79
|
+
/** Whether the run was aborted */
|
|
80
|
+
aborted: boolean;
|
|
81
|
+
/** Token usage */
|
|
82
|
+
usage: UsageInfo;
|
|
83
|
+
/** All messages in the conversation */
|
|
84
|
+
messages: Message[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Record of a single tool call
|
|
88
|
+
*/
|
|
89
|
+
export interface ToolCallRecord {
|
|
90
|
+
name: string;
|
|
91
|
+
input: Record<string, unknown>;
|
|
92
|
+
result: ToolExecutionResult;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Options for a single run
|
|
96
|
+
*/
|
|
97
|
+
export interface RunOptions {
|
|
98
|
+
/** AbortSignal for cancellation */
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
/** Override max iterations for this run */
|
|
101
|
+
maxIterations?: number;
|
|
102
|
+
/** Event handler for this run */
|
|
103
|
+
onEvent?: (event: AgentEvent) => void;
|
|
104
|
+
/** Filter tools for this run (allowlist) */
|
|
105
|
+
toolFilter?: string[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Configuration for creating a CompilrAgent
|
|
109
|
+
*/
|
|
110
|
+
export interface CompilrAgentConfig {
|
|
111
|
+
/** Provider type (auto-detected from env vars if omitted) */
|
|
112
|
+
provider?: ProviderType | LLMProvider;
|
|
113
|
+
/** Model name (uses provider default if omitted) */
|
|
114
|
+
model?: string;
|
|
115
|
+
/** API key (uses env var if omitted) */
|
|
116
|
+
apiKey?: string;
|
|
117
|
+
/** Preset to use. Default: 'coding' */
|
|
118
|
+
preset?: 'coding' | 'read-only' | 'none' | Preset;
|
|
119
|
+
/** Working directory. Default: process.cwd() */
|
|
120
|
+
cwd?: string;
|
|
121
|
+
/** Maximum iterations for tool use loops. Default: 50 */
|
|
122
|
+
maxIterations?: number;
|
|
123
|
+
/** System prompt. Overrides preset prompt. false = no prompt. */
|
|
124
|
+
systemPrompt?: string | false;
|
|
125
|
+
/** AbortSignal for cancellation */
|
|
126
|
+
signal?: AbortSignal;
|
|
127
|
+
/** Tool configuration (merged with preset tools) */
|
|
128
|
+
tools?: ToolConfig;
|
|
129
|
+
/** Permission mode. Default: 'auto' */
|
|
130
|
+
permissions?: 'auto' | 'read-only' | PermissionCallback;
|
|
131
|
+
/** Guardrail configuration. Default: true */
|
|
132
|
+
guardrails?: boolean | GuardrailConfig;
|
|
133
|
+
/** Lifecycle hooks */
|
|
134
|
+
hooks?: HooksConfig;
|
|
135
|
+
/** Context management configuration */
|
|
136
|
+
context?: ContextConfig;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* High-level agent interface
|
|
140
|
+
*/
|
|
141
|
+
export interface CompilrAgent {
|
|
142
|
+
/** Run the agent with a message and return the result */
|
|
143
|
+
run(message: string, options?: RunOptions): Promise<RunResult>;
|
|
144
|
+
/** Stream agent events */
|
|
145
|
+
stream(message: string, options?: RunOptions): AsyncIterable<AgentEvent>;
|
|
146
|
+
/** Multi-turn chat (alias for run, keeps history) */
|
|
147
|
+
chat(message: string, options?: RunOptions): Promise<RunResult>;
|
|
148
|
+
/** Add a tool at runtime */
|
|
149
|
+
addTool(tool: Tool): this;
|
|
150
|
+
/** Add an anchor (critical info that survives compaction) */
|
|
151
|
+
addAnchor(input: AnchorInput): this;
|
|
152
|
+
/** Get conversation history */
|
|
153
|
+
getHistory(): Message[];
|
|
154
|
+
/** Clear conversation history */
|
|
155
|
+
clearHistory(): this;
|
|
156
|
+
/** Get token usage info */
|
|
157
|
+
getUsage(): UsageInfo;
|
|
158
|
+
/** Get the underlying Agent instance */
|
|
159
|
+
unwrap(): unknown;
|
|
160
|
+
/** Abort the current run */
|
|
161
|
+
abort(): void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Configuration for a team agent member
|
|
165
|
+
*/
|
|
166
|
+
export interface TeamAgentConfig {
|
|
167
|
+
/** Role hint for the agent */
|
|
168
|
+
role?: 'architect' | 'developer' | 'tester' | 'reviewer';
|
|
169
|
+
/** System prompt for this agent */
|
|
170
|
+
systemPrompt?: string;
|
|
171
|
+
/** Model override for this agent */
|
|
172
|
+
model?: string;
|
|
173
|
+
/** Provider override for this agent */
|
|
174
|
+
provider?: ProviderType;
|
|
175
|
+
/** Tool name filter for this agent */
|
|
176
|
+
toolFilter?: string[];
|
|
177
|
+
/** Max iterations for this agent */
|
|
178
|
+
maxIterations?: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Team event (extends agent events with coordination info)
|
|
182
|
+
*/
|
|
183
|
+
export type TeamEvent = AgentEvent | {
|
|
184
|
+
type: 'team_agent_start';
|
|
185
|
+
agentName: string;
|
|
186
|
+
task: string;
|
|
187
|
+
} | {
|
|
188
|
+
type: 'team_agent_end';
|
|
189
|
+
agentName: string;
|
|
190
|
+
response: string;
|
|
191
|
+
} | {
|
|
192
|
+
type: 'team_done';
|
|
193
|
+
response: string;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Result of a team run
|
|
197
|
+
*/
|
|
198
|
+
export interface TeamResult {
|
|
199
|
+
/** Final coordinated response */
|
|
200
|
+
response: string;
|
|
201
|
+
/** Per-agent results */
|
|
202
|
+
agentResults: Record<string, RunResult>;
|
|
203
|
+
/** Total token usage across all agents */
|
|
204
|
+
usage: UsageInfo;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Configuration for creating a team
|
|
208
|
+
*/
|
|
209
|
+
export interface TeamConfig extends Omit<CompilrAgentConfig, 'systemPrompt'> {
|
|
210
|
+
/** Named agents in the team */
|
|
211
|
+
agents: Record<string, TeamAgentConfig>;
|
|
212
|
+
/** System prompt for the coordinator */
|
|
213
|
+
coordinatorPrompt?: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* High-level team interface
|
|
217
|
+
*/
|
|
218
|
+
export interface CompilrTeam {
|
|
219
|
+
/** Run the team with a message */
|
|
220
|
+
run(message: string, options?: RunOptions): Promise<TeamResult>;
|
|
221
|
+
/** Stream team events */
|
|
222
|
+
stream(message: string, options?: RunOptions): AsyncIterable<TeamEvent>;
|
|
223
|
+
/** Get a specific agent by name */
|
|
224
|
+
getAgent(name: string): CompilrAgent | undefined;
|
|
225
|
+
/** Abort all running agents */
|
|
226
|
+
abort(): void;
|
|
227
|
+
}
|
package/dist/config.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @compilr-dev/sdk — Universal Agent Runtime
|
|
3
|
+
*
|
|
4
|
+
* The single entry point for building AI-powered applications.
|
|
5
|
+
* Sits on top of @compilr-dev/agents and @compilr-dev/agents-coding,
|
|
6
|
+
* providing a high-level API for agent creation, tool assembly, and multi-agent teams.
|
|
7
|
+
*
|
|
8
|
+
* @example Three lines (coding default)
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createCompilrAgent } from '@compilr-dev/sdk';
|
|
11
|
+
* const agent = createCompilrAgent();
|
|
12
|
+
* const result = await agent.run('Fix the failing tests in src/auth/');
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example Custom domain (non-coding)
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { createCompilrAgent, defineTool, createSuccessResult } from '@compilr-dev/sdk';
|
|
18
|
+
*
|
|
19
|
+
* const myTool = defineTool({ name: 'search_kb', ... });
|
|
20
|
+
* const agent = createCompilrAgent({
|
|
21
|
+
* preset: 'none',
|
|
22
|
+
* systemPrompt: 'You are an HR assistant.',
|
|
23
|
+
* tools: { custom: [myTool] },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example Multi-agent team
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { createTeam } from '@compilr-dev/sdk';
|
|
30
|
+
* const team = createTeam({
|
|
31
|
+
* agents: { arch: { role: 'architect' }, dev: { role: 'developer' } },
|
|
32
|
+
* });
|
|
33
|
+
* await team.run('Add rate limiting to the API');
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export { createCompilrAgent } from './agent.js';
|
|
37
|
+
export { createTeam } from './team.js';
|
|
38
|
+
export type { CompilrAgentConfig, CompilrAgent, CompilrTeam, RunOptions, RunResult, ToolCallRecord, ToolConfig, TeamConfig, TeamAgentConfig, TeamResult, TeamEvent, UsageInfo, ProviderType, PermissionCallback, GuardrailConfig, ContextConfig, } from './config.js';
|
|
39
|
+
export { codingPreset, readOnlyPreset, resolvePreset } from './presets/index.js';
|
|
40
|
+
export type { Preset } from './presets/index.js';
|
|
41
|
+
export type { AnyTool } from './presets/types.js';
|
|
42
|
+
export { resolveProvider, detectProviderFromEnv, createProviderFromType } from './provider.js';
|
|
43
|
+
export { DEFAULT_MODELS, getContextWindow, DEFAULT_CONTEXT_WINDOW } from './models.js';
|
|
44
|
+
export { type ModelTier, type TierInfo, type ProviderModelMap, MODEL_TIERS, TIER_INFO, isValidTier, type ThinkingFormat, type ModelStatus, type ModelInfo, MODEL_REGISTRY, getModelsForProvider, getModelsSortedForDisplay, getModelInfo, isKnownModel, isModelSupported, getThinkingFormat, getStatusIndicator, getStatusLabel, getDefaultModelForTier, areThinkingFormatsCompatible, shouldClearHistoryOnModelChange, getModelContextWindow, getModelDisplayName, getModelDescription, getModelForTier, getTierMappings, getTierDisplayName, getShortModelName, getDefaultTierMappings, type ProviderMetadata, type OthersProviderModel, PROVIDER_METADATA, TOGETHER_MODELS, GROQ_MODELS, FIREWORKS_MODELS, PERPLEXITY_MODELS, OPENROUTER_MODELS, getModelsForOthersProvider, getOthersProviders, getProviderMetadata, isOthersProvider, } from './models/index.js';
|
|
45
|
+
export { assembleTools, deduplicateTools } from './tools.js';
|
|
46
|
+
export { defineTool, createSuccessResult, createErrorResult, mergeHooks, createLoggingHooks, createClaudeProvider, createOpenAIProvider, createGeminiNativeProvider, createOllamaProvider, createTogetherProvider, createGroqProvider, createFireworksProvider, createPerplexityProvider, createOpenRouterProvider, createMockProvider, MockProvider, Agent, AgentError, ProviderError, ToolError, ToolTimeoutError, MaxIterationsError, AbortError, } from '@compilr-dev/agents';
|
|
47
|
+
export type { Tool, HooksConfig, AgentEvent, Message, LLMProvider, AnchorInput, ToolExecutionResult, AgentRunResult, } from '@compilr-dev/agents';
|
|
48
|
+
export { readFileTool, writeFileTool, createBashTool, bashTool, bashOutputTool, killShellTool, grepTool, globTool, editTool, todoWriteTool, todoReadTool, createTodoTools, TodoStore, webFetchTool, suggestTool, } from '@compilr-dev/agents';
|
|
49
|
+
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
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @compilr-dev/sdk — Universal Agent Runtime
|
|
3
|
+
*
|
|
4
|
+
* The single entry point for building AI-powered applications.
|
|
5
|
+
* Sits on top of @compilr-dev/agents and @compilr-dev/agents-coding,
|
|
6
|
+
* providing a high-level API for agent creation, tool assembly, and multi-agent teams.
|
|
7
|
+
*
|
|
8
|
+
* @example Three lines (coding default)
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createCompilrAgent } from '@compilr-dev/sdk';
|
|
11
|
+
* const agent = createCompilrAgent();
|
|
12
|
+
* const result = await agent.run('Fix the failing tests in src/auth/');
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example Custom domain (non-coding)
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { createCompilrAgent, defineTool, createSuccessResult } from '@compilr-dev/sdk';
|
|
18
|
+
*
|
|
19
|
+
* const myTool = defineTool({ name: 'search_kb', ... });
|
|
20
|
+
* const agent = createCompilrAgent({
|
|
21
|
+
* preset: 'none',
|
|
22
|
+
* systemPrompt: 'You are an HR assistant.',
|
|
23
|
+
* tools: { custom: [myTool] },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example Multi-agent team
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { createTeam } from '@compilr-dev/sdk';
|
|
30
|
+
* const team = createTeam({
|
|
31
|
+
* agents: { arch: { role: 'architect' }, dev: { role: 'developer' } },
|
|
32
|
+
* });
|
|
33
|
+
* await team.run('Add rate limiting to the API');
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
// =============================================================================
|
|
37
|
+
// Core API
|
|
38
|
+
// =============================================================================
|
|
39
|
+
export { createCompilrAgent } from './agent.js';
|
|
40
|
+
export { createTeam } from './team.js';
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// Presets
|
|
43
|
+
// =============================================================================
|
|
44
|
+
export { codingPreset, readOnlyPreset, resolvePreset } from './presets/index.js';
|
|
45
|
+
// =============================================================================
|
|
46
|
+
// Provider Resolution
|
|
47
|
+
// =============================================================================
|
|
48
|
+
export { resolveProvider, detectProviderFromEnv, createProviderFromType } from './provider.js';
|
|
49
|
+
// =============================================================================
|
|
50
|
+
// Model Utilities (backward-compatible top-level)
|
|
51
|
+
// =============================================================================
|
|
52
|
+
export { DEFAULT_MODELS, getContextWindow, DEFAULT_CONTEXT_WINDOW } from './models.js';
|
|
53
|
+
// =============================================================================
|
|
54
|
+
// Model Registry, Tiers, Providers (full model system)
|
|
55
|
+
// =============================================================================
|
|
56
|
+
export { MODEL_TIERS, TIER_INFO, isValidTier, MODEL_REGISTRY, getModelsForProvider, getModelsSortedForDisplay, getModelInfo, isKnownModel, isModelSupported, getThinkingFormat, getStatusIndicator, getStatusLabel, getDefaultModelForTier, areThinkingFormatsCompatible, shouldClearHistoryOnModelChange, getModelContextWindow, getModelDisplayName, getModelDescription,
|
|
57
|
+
// Model tiers (pure, settings-free)
|
|
58
|
+
getModelForTier, getTierMappings, getTierDisplayName, getShortModelName, getDefaultTierMappings, PROVIDER_METADATA, TOGETHER_MODELS, GROQ_MODELS, FIREWORKS_MODELS, PERPLEXITY_MODELS, OPENROUTER_MODELS, getModelsForOthersProvider, getOthersProviders, getProviderMetadata, isOthersProvider, } from './models/index.js';
|
|
59
|
+
// =============================================================================
|
|
60
|
+
// Tool Assembly
|
|
61
|
+
// =============================================================================
|
|
62
|
+
export { assembleTools, deduplicateTools } from './tools.js';
|
|
63
|
+
// =============================================================================
|
|
64
|
+
// Re-exports from @compilr-dev/agents (convenience — no need to install separately)
|
|
65
|
+
// =============================================================================
|
|
66
|
+
export {
|
|
67
|
+
// Tool utilities
|
|
68
|
+
defineTool, createSuccessResult, createErrorResult,
|
|
69
|
+
// Hook utilities
|
|
70
|
+
mergeHooks, createLoggingHooks,
|
|
71
|
+
// Providers (for advanced usage)
|
|
72
|
+
createClaudeProvider, createOpenAIProvider, createGeminiNativeProvider, createOllamaProvider, createTogetherProvider, createGroqProvider, createFireworksProvider, createPerplexityProvider, createOpenRouterProvider, createMockProvider, MockProvider,
|
|
73
|
+
// Agent (escape hatch)
|
|
74
|
+
Agent,
|
|
75
|
+
// Error types
|
|
76
|
+
AgentError, ProviderError, ToolError, ToolTimeoutError, MaxIterationsError, AbortError, } from '@compilr-dev/agents';
|
|
77
|
+
// =============================================================================
|
|
78
|
+
// Individual Tool Re-exports (for consumers that build custom tool registries)
|
|
79
|
+
// =============================================================================
|
|
80
|
+
// Base tools from @compilr-dev/agents
|
|
81
|
+
export { readFileTool, writeFileTool, createBashTool, bashTool, bashOutputTool, killShellTool, grepTool, globTool, editTool, todoWriteTool, todoReadTool, createTodoTools, TodoStore, webFetchTool, suggestTool, } from '@compilr-dev/agents';
|
|
82
|
+
// Coding tools from @compilr-dev/agents-coding
|
|
83
|
+
export {
|
|
84
|
+
// Git
|
|
85
|
+
gitStatusTool, gitDiffTool, gitLogTool, gitCommitTool, gitBranchTool, gitStashTool, gitBlameTool, gitFileHistoryTool,
|
|
86
|
+
// Project detection
|
|
87
|
+
detectProjectTool, findProjectRootTool,
|
|
88
|
+
// Smart runners
|
|
89
|
+
runTestsTool, runLintTool, runBuildTool, runFormatTool,
|
|
90
|
+
// Code search
|
|
91
|
+
findDefinitionTool, findReferencesTool, findTodosTool,
|
|
92
|
+
// Dependencies
|
|
93
|
+
checkOutdatedTool, findVulnerabilitiesTool,
|
|
94
|
+
// Testing
|
|
95
|
+
analyzeTestCoverageTool,
|
|
96
|
+
// Unified analysis
|
|
97
|
+
getFileStructureTool, getComplexityTool,
|
|
98
|
+
// Bulk exports
|
|
99
|
+
allCodingTools, unifiedTools, } from '@compilr-dev/agents-coding';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Models Module — Barrel Export
|
|
3
|
+
*/
|
|
4
|
+
export { type ModelTier, type TierInfo, type ProviderModelMap, MODEL_TIERS, TIER_INFO, isValidTier, } from './types.js';
|
|
5
|
+
export { type ThinkingFormat, type ModelStatus, type ModelInfo, MODEL_REGISTRY, getModelsForProvider, getModelsSortedForDisplay, getModelInfo, isKnownModel, isModelSupported, getThinkingFormat, getStatusIndicator, getStatusLabel, getDefaultModelForTier, areThinkingFormatsCompatible, shouldClearHistoryOnModelChange, getModelContextWindow, getModelDisplayName, getModelDescription, } from './model-registry.js';
|
|
6
|
+
export { getModelForTier, getTierMappings, getTierDisplayName, getShortModelName, getDefaultTierMappings, } from './model-tiers.js';
|
|
7
|
+
export { type ProviderMetadata, type OthersProviderModel, PROVIDER_METADATA, TOGETHER_MODELS, GROQ_MODELS, FIREWORKS_MODELS, PERPLEXITY_MODELS, OPENROUTER_MODELS, getModelsForOthersProvider, getOthersProviders, getProviderMetadata, isOthersProvider, } from './providers.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Models Module — Barrel Export
|
|
3
|
+
*/
|
|
4
|
+
// Types & constants
|
|
5
|
+
export { MODEL_TIERS, TIER_INFO, isValidTier, } from './types.js';
|
|
6
|
+
// Model registry
|
|
7
|
+
export { MODEL_REGISTRY, getModelsForProvider, getModelsSortedForDisplay, getModelInfo, isKnownModel, isModelSupported, getThinkingFormat, getStatusIndicator, getStatusLabel, getDefaultModelForTier, areThinkingFormatsCompatible, shouldClearHistoryOnModelChange, getModelContextWindow, getModelDisplayName, getModelDescription, } from './model-registry.js';
|
|
8
|
+
// Model tiers (pure, settings-free)
|
|
9
|
+
export { getModelForTier, getTierMappings, getTierDisplayName, getShortModelName, getDefaultTierMappings, } from './model-tiers.js';
|
|
10
|
+
// Provider metadata
|
|
11
|
+
export { PROVIDER_METADATA, TOGETHER_MODELS, GROQ_MODELS, FIREWORKS_MODELS, PERPLEXITY_MODELS, OPENROUTER_MODELS, getModelsForOthersProvider, getOthersProviders, getProviderMetadata, isOthersProvider, } from './providers.js';
|