@drumcode/runner 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/README.md +139 -0
- package/dist/chunk-3CUTJWRW.mjs +358 -0
- package/dist/chunk-4ITFFQXW.mjs +716 -0
- package/dist/chunk-5NEEOHT4.mjs +632 -0
- package/dist/chunk-6BC7SCK5.mjs +720 -0
- package/dist/chunk-E3F3IKO5.mjs +359 -0
- package/dist/chunk-JN5YMFB7.mjs +1061 -0
- package/dist/chunk-T7I5AI3A.mjs +558 -0
- package/dist/chunk-VDJVZU3Q.mjs +908 -0
- package/dist/chunk-VYYR5EI4.mjs +1061 -0
- package/dist/chunk-ZOZS5KN7.mjs +713 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1432 -0
- package/dist/cli.mjs +360 -0
- package/dist/index.d.mts +192 -0
- package/dist/index.d.ts +192 -0
- package/dist/index.js +1085 -0
- package/dist/index.mjs +8 -0
- package/package.json +56 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { Tool } from '@drumcode/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const runnerOptionsSchema: z.ZodObject<{
|
|
5
|
+
token: z.ZodOptional<z.ZodString>;
|
|
6
|
+
project: z.ZodOptional<z.ZodString>;
|
|
7
|
+
registryUrl: z.ZodDefault<z.ZodString>;
|
|
8
|
+
cacheEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
logLevel: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
|
|
10
|
+
transport: z.ZodDefault<z.ZodEnum<["stdio", "sse"]>>;
|
|
11
|
+
/**
|
|
12
|
+
* Client mode affects how tools are exposed:
|
|
13
|
+
* - 'polyfill': Only expose core meta-tools (search + get_schema) - default for generic clients
|
|
14
|
+
* - 'full': Expose full manifest from registry - for clients that support large tool lists
|
|
15
|
+
*/
|
|
16
|
+
clientMode: z.ZodDefault<z.ZodEnum<["polyfill", "full"]>>;
|
|
17
|
+
/**
|
|
18
|
+
* Port for SSE server (only used when transport is 'sse')
|
|
19
|
+
*/
|
|
20
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
/**
|
|
22
|
+
* Host for SSE server (only used when transport is 'sse')
|
|
23
|
+
*/
|
|
24
|
+
host: z.ZodDefault<z.ZodString>;
|
|
25
|
+
/**
|
|
26
|
+
* Integration base URLs for registry tools (keyed by integration name)
|
|
27
|
+
*/
|
|
28
|
+
integrationBaseUrls: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
29
|
+
/**
|
|
30
|
+
* Integration headers for registry tools (keyed by integration name)
|
|
31
|
+
*/
|
|
32
|
+
integrationHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
registryUrl: string;
|
|
35
|
+
cacheEnabled: boolean;
|
|
36
|
+
logLevel: "info" | "debug" | "warn" | "error";
|
|
37
|
+
transport: "stdio" | "sse";
|
|
38
|
+
clientMode: "polyfill" | "full";
|
|
39
|
+
port: number;
|
|
40
|
+
host: string;
|
|
41
|
+
token?: string | undefined;
|
|
42
|
+
project?: string | undefined;
|
|
43
|
+
integrationBaseUrls?: Record<string, string> | undefined;
|
|
44
|
+
integrationHeaders?: Record<string, Record<string, string>> | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
token?: string | undefined;
|
|
47
|
+
project?: string | undefined;
|
|
48
|
+
registryUrl?: string | undefined;
|
|
49
|
+
cacheEnabled?: boolean | undefined;
|
|
50
|
+
logLevel?: "info" | "debug" | "warn" | "error" | undefined;
|
|
51
|
+
transport?: "stdio" | "sse" | undefined;
|
|
52
|
+
clientMode?: "polyfill" | "full" | undefined;
|
|
53
|
+
port?: number | undefined;
|
|
54
|
+
host?: string | undefined;
|
|
55
|
+
integrationBaseUrls?: Record<string, string> | undefined;
|
|
56
|
+
integrationHeaders?: Record<string, Record<string, string>> | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
type RunnerOptions = z.infer<typeof runnerOptionsSchema>;
|
|
59
|
+
interface ToolCallRequest {
|
|
60
|
+
name: string;
|
|
61
|
+
arguments: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
interface ToolCallResult {
|
|
64
|
+
content: Array<{
|
|
65
|
+
type: 'text' | 'image' | 'resource';
|
|
66
|
+
text?: string;
|
|
67
|
+
data?: string;
|
|
68
|
+
mimeType?: string;
|
|
69
|
+
}>;
|
|
70
|
+
isError?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface TokenValidationResponse {
|
|
73
|
+
valid: boolean;
|
|
74
|
+
project?: {
|
|
75
|
+
id: string;
|
|
76
|
+
};
|
|
77
|
+
token?: {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string | null;
|
|
80
|
+
profileId: string | null;
|
|
81
|
+
};
|
|
82
|
+
error?: {
|
|
83
|
+
code: string;
|
|
84
|
+
message: string;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
interface AuthenticatedContext {
|
|
88
|
+
isAuthenticated: boolean;
|
|
89
|
+
projectId: string | null;
|
|
90
|
+
tokenId: string | null;
|
|
91
|
+
tokenName: string | null;
|
|
92
|
+
profileId: string | null;
|
|
93
|
+
}
|
|
94
|
+
type ClientType = 'anthropic' | 'openai' | 'cursor' | 'langchain' | 'unknown';
|
|
95
|
+
interface ClientCapabilities {
|
|
96
|
+
type: ClientType;
|
|
97
|
+
supportsAdvancedToolUse: boolean;
|
|
98
|
+
supportsDeferredLoading: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare class DrumcodeRunner {
|
|
102
|
+
private options;
|
|
103
|
+
private toolCache;
|
|
104
|
+
private skillCache;
|
|
105
|
+
private manifestCache;
|
|
106
|
+
private authContext;
|
|
107
|
+
private authInitialized;
|
|
108
|
+
constructor(options: RunnerOptions);
|
|
109
|
+
/**
|
|
110
|
+
* Initialize authentication by validating the token with the registry
|
|
111
|
+
* This should be called before processing any requests
|
|
112
|
+
*/
|
|
113
|
+
initializeAuth(): Promise<AuthenticatedContext>;
|
|
114
|
+
/**
|
|
115
|
+
* Get the current authentication context
|
|
116
|
+
*/
|
|
117
|
+
getAuthContext(): AuthenticatedContext;
|
|
118
|
+
/**
|
|
119
|
+
* Check if the runner is authenticated
|
|
120
|
+
*/
|
|
121
|
+
isAuthenticated(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Get the list of tools to expose to the client
|
|
124
|
+
* Uses Polyfill strategy for non-Anthropic clients
|
|
125
|
+
*/
|
|
126
|
+
getToolList(capabilities: ClientCapabilities): Promise<Tool[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Fetch the full tool manifest from the Registry
|
|
129
|
+
*/
|
|
130
|
+
private getFullManifest;
|
|
131
|
+
/**
|
|
132
|
+
* Execute a tool call
|
|
133
|
+
*/
|
|
134
|
+
executeTool(request: ToolCallRequest): Promise<ToolCallResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Handle drumcode_search_tools meta-tool
|
|
137
|
+
*/
|
|
138
|
+
private handleSearchTools;
|
|
139
|
+
/**
|
|
140
|
+
* Handle drumcode_get_tool_schema meta-tool
|
|
141
|
+
*/
|
|
142
|
+
private handleGetToolSchema;
|
|
143
|
+
private fetchRegistryToolSchema;
|
|
144
|
+
/**
|
|
145
|
+
* Execute a regular (non-meta) tool
|
|
146
|
+
*/
|
|
147
|
+
private executeRegularTool;
|
|
148
|
+
private executeRegistryTool;
|
|
149
|
+
/**
|
|
150
|
+
* Fetch skill definition from registry
|
|
151
|
+
*/
|
|
152
|
+
private fetchSkill;
|
|
153
|
+
/**
|
|
154
|
+
* Execute a skill (validator or workflow)
|
|
155
|
+
*/
|
|
156
|
+
private executeSkill;
|
|
157
|
+
/**
|
|
158
|
+
* Evaluate a policy rule against context
|
|
159
|
+
* Simple expression evaluator for rules like "input.query && input.query.length >= 2"
|
|
160
|
+
*/
|
|
161
|
+
private evaluateRule;
|
|
162
|
+
/**
|
|
163
|
+
* Evaluate an argument mapping expression
|
|
164
|
+
* Supports expressions like "input.query", "input.max_results || 5", "steps.search_results.papers[0].id"
|
|
165
|
+
*/
|
|
166
|
+
private evaluateMapping;
|
|
167
|
+
/**
|
|
168
|
+
* Parse tool result content to extract structured data
|
|
169
|
+
*/
|
|
170
|
+
private parseToolResult;
|
|
171
|
+
/**
|
|
172
|
+
* Execute arXiv tools via the arXiv API
|
|
173
|
+
*/
|
|
174
|
+
private executeArxivTool;
|
|
175
|
+
/**
|
|
176
|
+
* Parse arXiv Atom XML response
|
|
177
|
+
*/
|
|
178
|
+
private parseArxivResponse;
|
|
179
|
+
private getIntegrationBaseUrl;
|
|
180
|
+
private getIntegrationHeaders;
|
|
181
|
+
private buildToolRequest;
|
|
182
|
+
private getAuthHeaders;
|
|
183
|
+
private formatToolSchema;
|
|
184
|
+
private log;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Create and configure the MCP server
|
|
189
|
+
*/
|
|
190
|
+
declare function createServer(options: RunnerOptions): Promise<void>;
|
|
191
|
+
|
|
192
|
+
export { type AuthenticatedContext, DrumcodeRunner, type RunnerOptions, type TokenValidationResponse, createServer };
|