@nemesis-oss/ollama-sdk 1.0.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/CHANGELOG.md +71 -0
- package/LICENSE +21 -0
- package/README.md +378 -0
- package/dist/compose-DC11aDJn.d.cts +430 -0
- package/dist/compose-DC11aDJn.d.ts +430 -0
- package/dist/index.cjs +2049 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1044 -0
- package/dist/index.d.ts +1044 -0
- package/dist/index.js +1969 -0
- package/dist/index.js.map +1 -0
- package/dist/skills.cjs +185 -0
- package/dist/skills.cjs.map +1 -0
- package/dist/skills.d.cts +19 -0
- package/dist/skills.d.ts +19 -0
- package/dist/skills.js +181 -0
- package/dist/skills.js.map +1 -0
- package/package.json +137 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core protocol and message types for the Ollama REST API.
|
|
5
|
+
*/
|
|
6
|
+
type Role = 'system' | 'user' | 'assistant' | 'tool' | 'thought';
|
|
7
|
+
interface ToolCallFunction {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly arguments: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Unlike OpenAI, Ollama's native `/api/chat` protocol does not assign an identifier to a
|
|
13
|
+
* tool call on the wire — a model turn's `tool_calls` array has no per-call ID from
|
|
14
|
+
* Ollama's side. `id` here is a **client-side synthesized value** (see
|
|
15
|
+
* `src/tools/tool-call-id.ts`), generated the first time the SDK sees a call without one
|
|
16
|
+
* and reused consistently afterward, so consumers get OpenAI-style `tool_call_id`
|
|
17
|
+
* correlation without the SDK depending on Ollama ever providing one. It carries no
|
|
18
|
+
* meaning to Ollama or the model — `ToolRegistry.executeToolCalls` still fundamentally
|
|
19
|
+
* dispatches by array position/order (straightforwardly parallel via `Promise.all` by
|
|
20
|
+
* default, or concurrency-bounded via `maxConcurrency`); `id` is a convenience layered on
|
|
21
|
+
* top for correlation/logging, not the underlying execution model. See ADR 0007.
|
|
22
|
+
*/
|
|
23
|
+
interface ToolCall {
|
|
24
|
+
/** Client-synthesized; see the type-level doc above. Always present once returned by this SDK. */
|
|
25
|
+
readonly id?: string | undefined;
|
|
26
|
+
readonly function: ToolCallFunction;
|
|
27
|
+
}
|
|
28
|
+
interface Message {
|
|
29
|
+
readonly role: Role;
|
|
30
|
+
readonly content: string;
|
|
31
|
+
readonly images?: readonly string[] | undefined;
|
|
32
|
+
readonly tool_calls?: readonly ToolCall[] | undefined;
|
|
33
|
+
/** Set on a `role: 'tool'` message to identify which {@link ToolCall.id} this answers. */
|
|
34
|
+
readonly tool_call_id?: string | undefined;
|
|
35
|
+
readonly thinking?: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
interface ToolProperty {
|
|
38
|
+
readonly type: string;
|
|
39
|
+
readonly description?: string | undefined;
|
|
40
|
+
readonly enum?: readonly string[] | undefined;
|
|
41
|
+
readonly items?: Record<string, unknown> | undefined;
|
|
42
|
+
readonly properties?: Record<string, unknown> | undefined;
|
|
43
|
+
readonly required?: readonly string[] | undefined;
|
|
44
|
+
}
|
|
45
|
+
interface ToolFunctionDefinition {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly description: string;
|
|
48
|
+
readonly parameters: {
|
|
49
|
+
readonly type: 'object';
|
|
50
|
+
readonly properties: Record<string, ToolProperty>;
|
|
51
|
+
readonly required?: readonly string[] | undefined;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
interface ToolDefinition {
|
|
55
|
+
readonly type: 'function';
|
|
56
|
+
readonly function: ToolFunctionDefinition;
|
|
57
|
+
}
|
|
58
|
+
type FormatOption = 'json' | Record<string, unknown>;
|
|
59
|
+
interface ModelOptions {
|
|
60
|
+
readonly num_keep?: number | undefined;
|
|
61
|
+
readonly seed?: number | undefined;
|
|
62
|
+
readonly num_predict?: number | undefined;
|
|
63
|
+
readonly top_k?: number | undefined;
|
|
64
|
+
readonly top_p?: number | undefined;
|
|
65
|
+
readonly min_p?: number | undefined;
|
|
66
|
+
readonly tfs_z?: number | undefined;
|
|
67
|
+
readonly typical_p?: number | undefined;
|
|
68
|
+
readonly repeat_last_n?: number | undefined;
|
|
69
|
+
readonly temperature?: number | undefined;
|
|
70
|
+
readonly repeat_penalty?: number | undefined;
|
|
71
|
+
readonly presence_penalty?: number | undefined;
|
|
72
|
+
readonly frequency_penalty?: number | undefined;
|
|
73
|
+
readonly mirostat?: number | undefined;
|
|
74
|
+
readonly mirostat_tau?: number | undefined;
|
|
75
|
+
readonly mirostat_eta?: number | undefined;
|
|
76
|
+
readonly penalize_newline?: boolean | undefined;
|
|
77
|
+
readonly stop?: readonly string[] | undefined;
|
|
78
|
+
readonly num_ctx?: number | undefined;
|
|
79
|
+
readonly num_batch?: number | undefined;
|
|
80
|
+
readonly num_gpu?: number | undefined;
|
|
81
|
+
readonly main_gpu?: number | undefined;
|
|
82
|
+
readonly low_vram?: boolean | undefined;
|
|
83
|
+
readonly f16_kv?: boolean | undefined;
|
|
84
|
+
readonly vocab_only?: boolean | undefined;
|
|
85
|
+
readonly use_mmap?: boolean | undefined;
|
|
86
|
+
readonly use_mlock?: boolean | undefined;
|
|
87
|
+
readonly num_thread?: number | undefined;
|
|
88
|
+
}
|
|
89
|
+
interface RequestCancellationOptions {
|
|
90
|
+
readonly signal?: AbortSignal | undefined;
|
|
91
|
+
readonly timeoutMs?: number | undefined;
|
|
92
|
+
}
|
|
93
|
+
interface ChatRequestOptions extends RequestCancellationOptions {
|
|
94
|
+
readonly model: string;
|
|
95
|
+
readonly messages: readonly Message[];
|
|
96
|
+
readonly tools?: readonly ToolDefinition[] | undefined;
|
|
97
|
+
readonly format?: FormatOption | undefined;
|
|
98
|
+
readonly options?: ModelOptions | undefined;
|
|
99
|
+
readonly stream?: boolean | undefined;
|
|
100
|
+
readonly keep_alive?: string | number | undefined;
|
|
101
|
+
readonly think?: boolean | 'low' | 'medium' | 'high' | 'max' | undefined;
|
|
102
|
+
}
|
|
103
|
+
interface ChatResponse {
|
|
104
|
+
readonly model: string;
|
|
105
|
+
readonly created_at: string;
|
|
106
|
+
readonly message: Message;
|
|
107
|
+
readonly done: boolean;
|
|
108
|
+
readonly done_reason?: string | undefined;
|
|
109
|
+
readonly total_duration?: number | undefined;
|
|
110
|
+
readonly load_duration?: number | undefined;
|
|
111
|
+
readonly prompt_eval_count?: number | undefined;
|
|
112
|
+
readonly prompt_eval_duration?: number | undefined;
|
|
113
|
+
readonly eval_count?: number | undefined;
|
|
114
|
+
readonly eval_duration?: number | undefined;
|
|
115
|
+
}
|
|
116
|
+
interface GenerateRequestOptions extends RequestCancellationOptions {
|
|
117
|
+
readonly model: string;
|
|
118
|
+
readonly prompt: string;
|
|
119
|
+
readonly suffix?: string | undefined;
|
|
120
|
+
readonly system?: string | undefined;
|
|
121
|
+
readonly template?: string | undefined;
|
|
122
|
+
readonly context?: readonly number[] | undefined;
|
|
123
|
+
readonly stream?: boolean | undefined;
|
|
124
|
+
readonly raw?: boolean | undefined;
|
|
125
|
+
readonly format?: FormatOption | undefined;
|
|
126
|
+
readonly images?: readonly string[] | undefined;
|
|
127
|
+
readonly options?: ModelOptions | undefined;
|
|
128
|
+
readonly keep_alive?: string | number | undefined;
|
|
129
|
+
readonly think?: boolean | 'low' | 'medium' | 'high' | 'max' | undefined;
|
|
130
|
+
}
|
|
131
|
+
interface GenerateResponse {
|
|
132
|
+
readonly model: string;
|
|
133
|
+
readonly created_at: string;
|
|
134
|
+
readonly response: string;
|
|
135
|
+
readonly done: boolean;
|
|
136
|
+
readonly done_reason?: string | undefined;
|
|
137
|
+
readonly context?: readonly number[] | undefined;
|
|
138
|
+
readonly total_duration?: number | undefined;
|
|
139
|
+
readonly load_duration?: number | undefined;
|
|
140
|
+
readonly prompt_eval_count?: number | undefined;
|
|
141
|
+
readonly prompt_eval_duration?: number | undefined;
|
|
142
|
+
readonly eval_count?: number | undefined;
|
|
143
|
+
readonly eval_duration?: number | undefined;
|
|
144
|
+
readonly thinking?: string | undefined;
|
|
145
|
+
}
|
|
146
|
+
interface EmbedRequestOptions extends RequestCancellationOptions {
|
|
147
|
+
readonly model: string;
|
|
148
|
+
readonly input: string | readonly string[];
|
|
149
|
+
readonly truncate?: boolean | undefined;
|
|
150
|
+
/** Truncates the returned embedding vectors to this many dimensions, if supported by the model. */
|
|
151
|
+
readonly dimensions?: number | undefined;
|
|
152
|
+
readonly options?: ModelOptions | undefined;
|
|
153
|
+
readonly keep_alive?: string | number | undefined;
|
|
154
|
+
}
|
|
155
|
+
interface EmbedResponse {
|
|
156
|
+
readonly model: string;
|
|
157
|
+
readonly embeddings: readonly (readonly number[])[];
|
|
158
|
+
readonly total_duration?: number | undefined;
|
|
159
|
+
readonly load_duration?: number | undefined;
|
|
160
|
+
readonly prompt_eval_count?: number | undefined;
|
|
161
|
+
}
|
|
162
|
+
interface EmbeddingsRequestOptions extends RequestCancellationOptions {
|
|
163
|
+
readonly model: string;
|
|
164
|
+
readonly prompt: string;
|
|
165
|
+
readonly options?: ModelOptions | undefined;
|
|
166
|
+
readonly keep_alive?: string | number | undefined;
|
|
167
|
+
}
|
|
168
|
+
interface EmbeddingsResponse {
|
|
169
|
+
readonly embedding: readonly number[];
|
|
170
|
+
}
|
|
171
|
+
interface ModelDetails {
|
|
172
|
+
readonly parent_model?: string | undefined;
|
|
173
|
+
readonly format: string;
|
|
174
|
+
readonly family: string;
|
|
175
|
+
readonly families?: readonly string[] | undefined;
|
|
176
|
+
readonly parameter_size: string;
|
|
177
|
+
readonly quantization_level: string;
|
|
178
|
+
}
|
|
179
|
+
interface ModelResponse {
|
|
180
|
+
readonly name: string;
|
|
181
|
+
readonly model: string;
|
|
182
|
+
readonly modified_at: string;
|
|
183
|
+
readonly size: number;
|
|
184
|
+
readonly digest: string;
|
|
185
|
+
readonly details: ModelDetails;
|
|
186
|
+
readonly expires_at?: string | undefined;
|
|
187
|
+
readonly size_vram?: number | undefined;
|
|
188
|
+
}
|
|
189
|
+
interface ListResponse {
|
|
190
|
+
readonly models: readonly ModelResponse[];
|
|
191
|
+
}
|
|
192
|
+
interface ShowRequestOptions extends RequestCancellationOptions {
|
|
193
|
+
readonly model: string;
|
|
194
|
+
readonly system?: string | undefined;
|
|
195
|
+
readonly template?: string | undefined;
|
|
196
|
+
readonly verbose?: boolean | undefined;
|
|
197
|
+
}
|
|
198
|
+
interface ShowResponse {
|
|
199
|
+
readonly license?: string | undefined;
|
|
200
|
+
readonly modelfile?: string | undefined;
|
|
201
|
+
readonly parameters?: string | undefined;
|
|
202
|
+
readonly template?: string | undefined;
|
|
203
|
+
readonly system?: string | undefined;
|
|
204
|
+
readonly details: ModelDetails;
|
|
205
|
+
readonly messages?: readonly Message[] | undefined;
|
|
206
|
+
readonly model_info?: Record<string, unknown> | undefined;
|
|
207
|
+
readonly capabilities?: readonly string[] | undefined;
|
|
208
|
+
readonly modified_at?: string | undefined;
|
|
209
|
+
}
|
|
210
|
+
interface ProgressResponse {
|
|
211
|
+
readonly status: string;
|
|
212
|
+
readonly digest?: string | undefined;
|
|
213
|
+
readonly total?: number | undefined;
|
|
214
|
+
readonly completed?: number | undefined;
|
|
215
|
+
}
|
|
216
|
+
interface PullRequestOptions extends RequestCancellationOptions {
|
|
217
|
+
readonly model: string;
|
|
218
|
+
readonly insecure?: boolean | undefined;
|
|
219
|
+
readonly stream?: boolean | undefined;
|
|
220
|
+
}
|
|
221
|
+
interface PushRequestOptions extends RequestCancellationOptions {
|
|
222
|
+
readonly model: string;
|
|
223
|
+
readonly insecure?: boolean | undefined;
|
|
224
|
+
readonly stream?: boolean | undefined;
|
|
225
|
+
}
|
|
226
|
+
interface CreateRequestOptions extends RequestCancellationOptions {
|
|
227
|
+
readonly model: string;
|
|
228
|
+
readonly modelfile?: string | undefined;
|
|
229
|
+
readonly stream?: boolean | undefined;
|
|
230
|
+
readonly quantize?: string | undefined;
|
|
231
|
+
readonly from?: string | undefined;
|
|
232
|
+
readonly files?: Record<string, string> | undefined;
|
|
233
|
+
readonly adapters?: Record<string, string> | undefined;
|
|
234
|
+
}
|
|
235
|
+
interface DeleteRequestOptions extends RequestCancellationOptions {
|
|
236
|
+
readonly model: string;
|
|
237
|
+
}
|
|
238
|
+
interface CopyRequestOptions extends RequestCancellationOptions {
|
|
239
|
+
readonly source: string;
|
|
240
|
+
readonly destination: string;
|
|
241
|
+
}
|
|
242
|
+
interface StatusResponse {
|
|
243
|
+
readonly status: string;
|
|
244
|
+
}
|
|
245
|
+
interface VersionResponse {
|
|
246
|
+
readonly version: string;
|
|
247
|
+
}
|
|
248
|
+
interface PsResponse {
|
|
249
|
+
readonly models: readonly ModelResponse[];
|
|
250
|
+
}
|
|
251
|
+
interface WebSearchRequestOptions extends RequestCancellationOptions {
|
|
252
|
+
readonly query: string;
|
|
253
|
+
readonly count?: number | undefined;
|
|
254
|
+
}
|
|
255
|
+
interface WebSearchResult {
|
|
256
|
+
readonly title: string;
|
|
257
|
+
readonly url: string;
|
|
258
|
+
readonly snippet: string;
|
|
259
|
+
}
|
|
260
|
+
interface WebSearchResponse {
|
|
261
|
+
readonly results: readonly WebSearchResult[];
|
|
262
|
+
}
|
|
263
|
+
interface WebFetchRequestOptions extends RequestCancellationOptions {
|
|
264
|
+
readonly url: string;
|
|
265
|
+
}
|
|
266
|
+
interface WebFetchResponse {
|
|
267
|
+
readonly content: string;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Tool definition, handler, and execution types.
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
interface ToolExecutionContext {
|
|
275
|
+
readonly signal?: AbortSignal | undefined;
|
|
276
|
+
}
|
|
277
|
+
type ToolHandler<TParams, TResult> = (params: TParams, context: ToolExecutionContext) => Promise<TResult> | TResult;
|
|
278
|
+
interface Tool<TParams = Record<string, unknown>, TResult = unknown> {
|
|
279
|
+
readonly name: string;
|
|
280
|
+
readonly description: string;
|
|
281
|
+
readonly schema: z.ZodType<TParams>;
|
|
282
|
+
readonly execute: ToolHandler<TParams, TResult>;
|
|
283
|
+
readonly definition: ToolDefinition;
|
|
284
|
+
/**
|
|
285
|
+
* Per-tool execution timeout in milliseconds, overriding the registry's default.
|
|
286
|
+
* Pass `0` to explicitly disable timeout enforcement for this tool.
|
|
287
|
+
*/
|
|
288
|
+
readonly timeoutMs?: number | undefined;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* A `Tool` of *any* parameter shape, for heterogeneous collections — i.e. what
|
|
292
|
+
* `ToolRegistry` stores and accepts.
|
|
293
|
+
*
|
|
294
|
+
* `Tool<TParams>` is **invariant** in `TParams`, because `TParams` appears both
|
|
295
|
+
* covariantly (`schema: z.ZodType<TParams>`) and contravariantly
|
|
296
|
+
* (`execute: ToolHandler<TParams, …>`). That makes `Tool<never, unknown>` — the obvious-
|
|
297
|
+
* looking "bottom" type for a mixed collection — assignable from *nothing*: a perfectly
|
|
298
|
+
* ordinary `Tool<{ city: string }, string>` from `defineTool` is rejected by it. `any` is
|
|
299
|
+
* the standard escape hatch for exactly this case, and it is confined to this one alias:
|
|
300
|
+
* `defineTool` still infers `TParams` from the Zod schema and still type-checks `execute`
|
|
301
|
+
* against it, so tool authoring keeps full type safety. Only the registry's *storage*
|
|
302
|
+
* type is widened, and the registry never does anything with a tool's params beyond
|
|
303
|
+
* handing `schema.safeParse`'s validated output straight back to that same tool's
|
|
304
|
+
* `execute`.
|
|
305
|
+
*/
|
|
306
|
+
type AnyTool = Tool<any, unknown>;
|
|
307
|
+
interface ToolExecutionSuccess {
|
|
308
|
+
readonly toolName: string;
|
|
309
|
+
/** Echoes the originating {@link ToolCall.id}, if the call had one. */
|
|
310
|
+
readonly toolCallId?: string | undefined;
|
|
311
|
+
readonly success: true;
|
|
312
|
+
readonly result: unknown;
|
|
313
|
+
readonly outputString: string;
|
|
314
|
+
}
|
|
315
|
+
interface ToolExecutionFailure {
|
|
316
|
+
readonly toolName: string;
|
|
317
|
+
/** Echoes the originating {@link ToolCall.id}, if the call had one. */
|
|
318
|
+
readonly toolCallId?: string | undefined;
|
|
319
|
+
readonly success: false;
|
|
320
|
+
readonly error: Error;
|
|
321
|
+
readonly outputString: string;
|
|
322
|
+
}
|
|
323
|
+
type ToolExecutionResult = ToolExecutionSuccess | ToolExecutionFailure;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Tool registry for managing definitions and executing model tool calls.
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
interface ToolRegistryOptions {
|
|
330
|
+
readonly tools?: readonly AnyTool[] | undefined;
|
|
331
|
+
readonly onError?: ((error: Error, toolCall: ToolCall) => string) | undefined;
|
|
332
|
+
/**
|
|
333
|
+
* Default per-call execution timeout in milliseconds, applied to any tool that
|
|
334
|
+
* doesn't declare its own `timeoutMs`. Undefined (the default) means no timeout is
|
|
335
|
+
* enforced, matching prior behavior. Recommended whenever tool arguments or
|
|
336
|
+
* implementations are influenced by model output you don't fully control, since an
|
|
337
|
+
* unbounded tool call can otherwise stall the entire agent loop indefinitely.
|
|
338
|
+
*
|
|
339
|
+
* Enforcement is cooperative: it races the tool's promise against a timer and
|
|
340
|
+
* reports a timeout failure, but cannot forcibly halt synchronous or non-abort-aware
|
|
341
|
+
* asynchronous work already in flight on the same thread. Tools that perform I/O
|
|
342
|
+
* should honor `ToolExecutionContext.signal` to stop promptly on timeout.
|
|
343
|
+
*/
|
|
344
|
+
readonly timeoutMs?: number | undefined;
|
|
345
|
+
/**
|
|
346
|
+
* Maximum number of tool calls executed concurrently by `executeToolCalls`.
|
|
347
|
+
* Undefined (the default) runs all calls in parallel, matching prior behavior.
|
|
348
|
+
*/
|
|
349
|
+
readonly maxConcurrency?: number | undefined;
|
|
350
|
+
/**
|
|
351
|
+
* Maximum length of a tool's `outputString` before it is truncated. Guards against a
|
|
352
|
+
* single tool call flooding the conversation history / model context (and process
|
|
353
|
+
* memory) with unbounded output. Undefined (the default) applies no limit.
|
|
354
|
+
*/
|
|
355
|
+
readonly maxOutputChars?: number | undefined;
|
|
356
|
+
}
|
|
357
|
+
declare class ToolRegistry {
|
|
358
|
+
private readonly tools;
|
|
359
|
+
private readonly onError?;
|
|
360
|
+
private readonly defaultTimeoutMs?;
|
|
361
|
+
private readonly maxConcurrency?;
|
|
362
|
+
private readonly maxOutputChars?;
|
|
363
|
+
constructor(toolsOrOptions?: readonly AnyTool[] | ToolRegistryOptions | undefined);
|
|
364
|
+
register(tool: AnyTool): this;
|
|
365
|
+
registerMany(tools: readonly AnyTool[]): this;
|
|
366
|
+
get(name: string): AnyTool | undefined;
|
|
367
|
+
definitions(): ToolDefinition[];
|
|
368
|
+
executeToolCall(toolCall: ToolCall, ctx?: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
369
|
+
private executeToolCallUninstrumented;
|
|
370
|
+
/**
|
|
371
|
+
* Executes every call in `toolCalls` and returns results in the same order, so results
|
|
372
|
+
* are always correlatable by array position regardless of `id`. Each result also echoes
|
|
373
|
+
* its call's `toolCallId` for callers who'd rather match by ID — see the {@link ToolCall}
|
|
374
|
+
* docs for how that id is produced. Runs fully in parallel (`Promise.all`) unless
|
|
375
|
+
* `maxConcurrency` was configured, in which case a bounded worker pool is used instead.
|
|
376
|
+
*/
|
|
377
|
+
executeToolCalls(toolCalls: readonly ToolCall[], ctx?: ToolExecutionContext): Promise<ToolExecutionResult[]>;
|
|
378
|
+
private runWithTimeout;
|
|
379
|
+
private truncateOutput;
|
|
380
|
+
private handleExecutionError;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* SKILL.md frontmatter and skill registry types.
|
|
385
|
+
*/
|
|
386
|
+
interface SkillFrontmatter {
|
|
387
|
+
readonly name: string;
|
|
388
|
+
readonly description: string;
|
|
389
|
+
readonly 'allowed-tools'?: readonly string[] | undefined;
|
|
390
|
+
readonly [key: string]: unknown;
|
|
391
|
+
}
|
|
392
|
+
interface SkillSummary {
|
|
393
|
+
readonly name: string;
|
|
394
|
+
readonly description: string;
|
|
395
|
+
readonly path: string;
|
|
396
|
+
}
|
|
397
|
+
interface Skill extends SkillSummary {
|
|
398
|
+
readonly frontmatter: SkillFrontmatter;
|
|
399
|
+
readonly body: string;
|
|
400
|
+
readonly allowedTools?: readonly string[] | undefined;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Lightweight frontmatter parser for SKILL.md files.
|
|
405
|
+
*/
|
|
406
|
+
|
|
407
|
+
interface ParsedFrontmatter {
|
|
408
|
+
readonly frontmatter: SkillFrontmatter;
|
|
409
|
+
readonly body: string;
|
|
410
|
+
}
|
|
411
|
+
declare function parseFrontmatter(source: string, path?: string): ParsedFrontmatter;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Skill composition and context injection.
|
|
415
|
+
*/
|
|
416
|
+
|
|
417
|
+
interface ApplySkillOptions {
|
|
418
|
+
readonly messages: readonly Message[];
|
|
419
|
+
readonly tools?: ToolRegistry;
|
|
420
|
+
}
|
|
421
|
+
interface AppliedSkillResult {
|
|
422
|
+
readonly messages: readonly Message[];
|
|
423
|
+
readonly tools?: ToolRegistry;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Injects a skill's body into messages as a system prompt and applies allowed tool filters.
|
|
427
|
+
*/
|
|
428
|
+
declare function applySkill(skill: Skill, options: ApplySkillOptions): AppliedSkillResult;
|
|
429
|
+
|
|
430
|
+
export { parseFrontmatter as $, type AnyTool as A, type Role as B, type ChatResponse as C, type DeleteRequestOptions as D, type EmbedRequestOptions as E, type FormatOption as F, type GenerateResponse as G, type Skill as H, type SkillFrontmatter as I, type SkillSummary as J, type ToolCallFunction as K, type ListResponse as L, type Message as M, type ToolExecutionContext as N, type ToolExecutionFailure as O, type ProgressResponse as P, type ToolExecutionSuccess as Q, type RequestCancellationOptions as R, type ShowRequestOptions as S, type ToolCall as T, type ToolFunctionDefinition as U, type VersionResponse as V, type WebSearchRequestOptions as W, type ToolProperty as X, type ToolRegistryOptions as Y, type WebSearchResult as Z, applySkill as _, type ModelResponse as a, type ShowResponse as b, type PullRequestOptions as c, type PushRequestOptions as d, type CreateRequestOptions as e, type StatusResponse as f, type CopyRequestOptions as g, type PsResponse as h, type ChatRequestOptions as i, type GenerateRequestOptions as j, type EmbedResponse as k, type EmbeddingsRequestOptions as l, type EmbeddingsResponse as m, type WebSearchResponse as n, type WebFetchRequestOptions as o, type WebFetchResponse as p, type ToolHandler as q, type Tool as r, ToolRegistry as s, type ToolExecutionResult as t, type ModelOptions as u, type ToolDefinition as v, type AppliedSkillResult as w, type ApplySkillOptions as x, type ModelDetails as y, type ParsedFrontmatter as z };
|