@elisym/sdk 0.12.4 → 0.12.5
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/skills.cjs +392 -88
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.d.cts +183 -3
- package/dist/skills.d.ts +183 -3
- package/dist/skills.js +385 -89
- package/dist/skills.js.map +1 -1
- package/package.json +1 -1
package/dist/skills.d.cts
CHANGED
|
@@ -17,11 +17,22 @@ interface SkillOutput {
|
|
|
17
17
|
outputMime?: string;
|
|
18
18
|
}
|
|
19
19
|
interface SkillContext {
|
|
20
|
+
/** Required only when the routed skill has `mode === 'llm'`. */
|
|
20
21
|
llm?: LlmClient;
|
|
21
22
|
agentName: string;
|
|
22
23
|
agentDescription: string;
|
|
23
24
|
signal?: AbortSignal;
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* How the runtime produces a result for a job:
|
|
28
|
+
* - `llm`: feed input through Anthropic/OpenAI with the skill's system prompt (default).
|
|
29
|
+
* - `static-file`: return the contents of a fixed file. No input required.
|
|
30
|
+
* - `static-script`: spawn a script with no stdin. No input required.
|
|
31
|
+
* - `dynamic-script`: spawn a script and pipe the user's input to stdin.
|
|
32
|
+
*
|
|
33
|
+
* Static modes set `card.static = true` so the webapp hides its input box.
|
|
34
|
+
*/
|
|
35
|
+
type SkillMode = 'llm' | 'static-file' | 'static-script' | 'dynamic-script';
|
|
25
36
|
interface ToolDef {
|
|
26
37
|
name: string;
|
|
27
38
|
description: string;
|
|
@@ -61,6 +72,8 @@ interface Skill {
|
|
|
61
72
|
priceSubunits: bigint;
|
|
62
73
|
/** Asset the price is denominated in (NATIVE_SOL or USDC_SOLANA_DEVNET, etc.). */
|
|
63
74
|
asset: Asset;
|
|
75
|
+
/** Execution mode. Default 'llm' for back-compat. */
|
|
76
|
+
mode: SkillMode;
|
|
64
77
|
image?: string;
|
|
65
78
|
imageFile?: string;
|
|
66
79
|
execute(input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
|
|
@@ -77,6 +90,8 @@ declare function createAnthropicClient(config: Omit<LlmClientConfig, 'provider'>
|
|
|
77
90
|
declare function createOpenAIClient(config: Omit<LlmClientConfig, 'provider'>): LlmClient;
|
|
78
91
|
declare function createLlmClient(config: LlmClientConfig): LlmClient;
|
|
79
92
|
|
|
93
|
+
declare const MAX_SCRIPT_OUTPUT = 1000000;
|
|
94
|
+
declare const DEFAULT_SCRIPT_TIMEOUT_MS = 60000;
|
|
80
95
|
interface SkillToolDef {
|
|
81
96
|
name: string;
|
|
82
97
|
description: string;
|
|
@@ -90,6 +105,35 @@ interface SkillToolDef {
|
|
|
90
105
|
interface ScriptSkillLogger {
|
|
91
106
|
debug?(obj: Record<string, unknown>, msg?: string): void;
|
|
92
107
|
}
|
|
108
|
+
interface RunScriptOptions {
|
|
109
|
+
cwd: string;
|
|
110
|
+
/**
|
|
111
|
+
* UTF-8 string written to the child's stdin, then stdin closed.
|
|
112
|
+
* When undefined, stdin is closed immediately (EOF) so that children
|
|
113
|
+
* which read stdin do not block until `timeoutMs`.
|
|
114
|
+
*/
|
|
115
|
+
stdin?: string;
|
|
116
|
+
/** Cancel the spawn. SIGKILL is sent on abort. */
|
|
117
|
+
signal?: AbortSignal;
|
|
118
|
+
/** Hard timeout in ms. Default `DEFAULT_SCRIPT_TIMEOUT_MS`. */
|
|
119
|
+
timeoutMs?: number;
|
|
120
|
+
/** Cap on stdout/stderr capture. Default `MAX_SCRIPT_OUTPUT`. */
|
|
121
|
+
maxOutput?: number;
|
|
122
|
+
}
|
|
123
|
+
interface RunScriptResult {
|
|
124
|
+
stdout: string;
|
|
125
|
+
stderr: string;
|
|
126
|
+
/** Null when the process was killed by signal before exiting. */
|
|
127
|
+
code: number | null;
|
|
128
|
+
/** Set when spawn itself failed (ENOENT, EACCES, etc.). */
|
|
129
|
+
spawnError?: Error;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Spawn `cmd` with `args` and capture stdout/stderr. Never uses `shell: true`,
|
|
133
|
+
* so shell metacharacters in arguments are safe. Caller is responsible for
|
|
134
|
+
* checking `code === 0` / interpreting `spawnError`.
|
|
135
|
+
*/
|
|
136
|
+
declare function runScript(cmd: string, args: string[], opts: RunScriptOptions): Promise<RunScriptResult>;
|
|
93
137
|
interface ScriptSkillParams {
|
|
94
138
|
name: string;
|
|
95
139
|
description: string;
|
|
@@ -117,6 +161,7 @@ declare class ScriptSkill implements Skill {
|
|
|
117
161
|
capabilities: string[];
|
|
118
162
|
priceSubunits: bigint;
|
|
119
163
|
asset: Asset;
|
|
164
|
+
mode: SkillMode;
|
|
120
165
|
image?: string;
|
|
121
166
|
imageFile?: string;
|
|
122
167
|
private skillDir;
|
|
@@ -129,6 +174,122 @@ declare class ScriptSkill implements Skill {
|
|
|
129
174
|
private runTool;
|
|
130
175
|
}
|
|
131
176
|
|
|
177
|
+
/** Hard ceiling on result size for static-file skills. NIP-90 result events
|
|
178
|
+
* travel through relays that may reject very large payloads; cap at 256 KB
|
|
179
|
+
* of UTF-8. Larger files should use a script that streams to an external host. */
|
|
180
|
+
declare const MAX_STATIC_FILE_SIZE: number;
|
|
181
|
+
interface StaticFileSkillParams {
|
|
182
|
+
name: string;
|
|
183
|
+
description: string;
|
|
184
|
+
capabilities: string[];
|
|
185
|
+
priceSubunits: bigint;
|
|
186
|
+
asset: Asset;
|
|
187
|
+
/** Absolute path to the file whose contents are returned on each job. */
|
|
188
|
+
outputFilePath: string;
|
|
189
|
+
image?: string;
|
|
190
|
+
imageFile?: string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Returns the contents of a fixed file as the job result. Reads on every
|
|
194
|
+
* `execute()` so authors can edit the file without restarting the agent.
|
|
195
|
+
*/
|
|
196
|
+
declare class StaticFileSkill implements Skill {
|
|
197
|
+
name: string;
|
|
198
|
+
description: string;
|
|
199
|
+
capabilities: string[];
|
|
200
|
+
priceSubunits: bigint;
|
|
201
|
+
asset: Asset;
|
|
202
|
+
mode: SkillMode;
|
|
203
|
+
image?: string;
|
|
204
|
+
imageFile?: string;
|
|
205
|
+
private outputFilePath;
|
|
206
|
+
constructor(params: StaticFileSkillParams);
|
|
207
|
+
execute(_input: SkillInput, _ctx: SkillContext): Promise<SkillOutput>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface StaticScriptSkillParams {
|
|
211
|
+
name: string;
|
|
212
|
+
description: string;
|
|
213
|
+
capabilities: string[];
|
|
214
|
+
priceSubunits: bigint;
|
|
215
|
+
asset: Asset;
|
|
216
|
+
/** Absolute path to the script. */
|
|
217
|
+
scriptPath: string;
|
|
218
|
+
/** Extra args appended after the script path. */
|
|
219
|
+
scriptArgs: string[];
|
|
220
|
+
/** Optional override of the default 60s timeout. */
|
|
221
|
+
scriptTimeoutMs?: number;
|
|
222
|
+
image?: string;
|
|
223
|
+
imageFile?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Spawns a configured script with no stdin and returns its trimmed stdout.
|
|
227
|
+
* Throws on non-zero exit so the runtime surfaces a sanitized error.
|
|
228
|
+
* The script runs with cwd set to its containing directory so relative
|
|
229
|
+
* paths inside the script behave intuitively.
|
|
230
|
+
*/
|
|
231
|
+
declare class StaticScriptSkill implements Skill {
|
|
232
|
+
name: string;
|
|
233
|
+
description: string;
|
|
234
|
+
capabilities: string[];
|
|
235
|
+
priceSubunits: bigint;
|
|
236
|
+
asset: Asset;
|
|
237
|
+
mode: SkillMode;
|
|
238
|
+
image?: string;
|
|
239
|
+
imageFile?: string;
|
|
240
|
+
private scriptPath;
|
|
241
|
+
private scriptArgs;
|
|
242
|
+
private scriptTimeoutMs?;
|
|
243
|
+
constructor(params: StaticScriptSkillParams);
|
|
244
|
+
execute(_input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface DynamicScriptSkillParams {
|
|
248
|
+
name: string;
|
|
249
|
+
description: string;
|
|
250
|
+
capabilities: string[];
|
|
251
|
+
priceSubunits: bigint;
|
|
252
|
+
asset: Asset;
|
|
253
|
+
/** Absolute path to the script. */
|
|
254
|
+
scriptPath: string;
|
|
255
|
+
/** Extra args appended after the script path. */
|
|
256
|
+
scriptArgs: string[];
|
|
257
|
+
/** Optional override of the default 60s timeout. */
|
|
258
|
+
scriptTimeoutMs?: number;
|
|
259
|
+
image?: string;
|
|
260
|
+
imageFile?: string;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Pipes the user's job input to the script's stdin and returns its
|
|
264
|
+
* trimmed stdout. Enables script-backed capabilities (proxies to
|
|
265
|
+
* external models, classical NLP, custom workers) without an LLM key
|
|
266
|
+
* on the elisym side.
|
|
267
|
+
*/
|
|
268
|
+
declare class DynamicScriptSkill implements Skill {
|
|
269
|
+
name: string;
|
|
270
|
+
description: string;
|
|
271
|
+
capabilities: string[];
|
|
272
|
+
priceSubunits: bigint;
|
|
273
|
+
asset: Asset;
|
|
274
|
+
mode: SkillMode;
|
|
275
|
+
image?: string;
|
|
276
|
+
imageFile?: string;
|
|
277
|
+
private scriptPath;
|
|
278
|
+
private scriptArgs;
|
|
279
|
+
private scriptTimeoutMs?;
|
|
280
|
+
constructor(params: DynamicScriptSkillParams);
|
|
281
|
+
execute(input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Resolve `value` relative to `rootDir` and reject anything that escapes
|
|
286
|
+
* the root (`..` segments, absolute paths outside it, or the root itself).
|
|
287
|
+
*
|
|
288
|
+
* Returns the absolute path on success, or null on rejection so callers
|
|
289
|
+
* can surface a precise error message.
|
|
290
|
+
*/
|
|
291
|
+
declare function resolveInsidePath(rootDir: string, value: string): string | null;
|
|
292
|
+
|
|
132
293
|
declare const DEFAULT_MAX_TOOL_ROUNDS = 10;
|
|
133
294
|
interface SkillFrontmatter {
|
|
134
295
|
name?: unknown;
|
|
@@ -143,6 +304,16 @@ interface SkillFrontmatter {
|
|
|
143
304
|
image_file?: unknown;
|
|
144
305
|
tools?: unknown;
|
|
145
306
|
max_tool_rounds?: unknown;
|
|
307
|
+
/** Execution mode. Default 'llm'. */
|
|
308
|
+
mode?: unknown;
|
|
309
|
+
/** Required when mode === 'static-file'. Path relative to skill dir. */
|
|
310
|
+
output_file?: unknown;
|
|
311
|
+
/** Required when mode === 'static-script' | 'dynamic-script'. Path relative to skill dir. */
|
|
312
|
+
script?: unknown;
|
|
313
|
+
/** Optional positional args appended after the script. */
|
|
314
|
+
script_args?: unknown;
|
|
315
|
+
/** Optional override of `DEFAULT_SCRIPT_TIMEOUT_MS`. */
|
|
316
|
+
script_timeout_ms?: unknown;
|
|
146
317
|
}
|
|
147
318
|
interface ParsedSkill {
|
|
148
319
|
name: string;
|
|
@@ -151,11 +322,20 @@ interface ParsedSkill {
|
|
|
151
322
|
/** Price in subunits of `asset`. */
|
|
152
323
|
priceSubunits: bigint;
|
|
153
324
|
asset: Asset;
|
|
325
|
+
mode: SkillMode;
|
|
154
326
|
systemPrompt: string;
|
|
155
327
|
tools: SkillToolDef[];
|
|
156
328
|
maxToolRounds: number;
|
|
157
329
|
image?: string;
|
|
158
330
|
imageFile?: string;
|
|
331
|
+
/** Set when mode === 'static-file'. */
|
|
332
|
+
outputFile?: string;
|
|
333
|
+
/** Set when mode is a script mode. */
|
|
334
|
+
script?: string;
|
|
335
|
+
/** Empty when no script. */
|
|
336
|
+
scriptArgs: string[];
|
|
337
|
+
/** Undefined => caller uses `DEFAULT_SCRIPT_TIMEOUT_MS`. */
|
|
338
|
+
scriptTimeoutMs?: number;
|
|
159
339
|
}
|
|
160
340
|
interface LoaderLogger {
|
|
161
341
|
debug?(obj: Record<string, unknown>, msg?: string): void;
|
|
@@ -177,9 +357,9 @@ declare function parseSkillMd(content: string): {
|
|
|
177
357
|
declare function validateSkillFrontmatter(frontmatter: SkillFrontmatter, systemPrompt: string, options?: LoadSkillsOptions): ParsedSkill;
|
|
178
358
|
/**
|
|
179
359
|
* Walk `skillsDir`, load each immediate subdirectory's SKILL.md, and
|
|
180
|
-
* return constructed `
|
|
181
|
-
* skipped with a `warn` log.
|
|
360
|
+
* return constructed `Skill` instances (LLM or non-LLM depending on
|
|
361
|
+
* frontmatter `mode`). Malformed directories are skipped with a `warn` log.
|
|
182
362
|
*/
|
|
183
363
|
declare function loadSkillsFromDir(skillsDir: string, options?: LoadSkillsOptions): Skill[];
|
|
184
364
|
|
|
185
|
-
export { type CompletionResult, DEFAULT_MAX_TOOL_ROUNDS, type LlmClient, type LlmClientConfig, type LlmProvider, type LoadSkillsOptions, type LoaderLogger, type ParsedSkill, ScriptSkill, type ScriptSkillLogger, type ScriptSkillParams, type Skill, type SkillContext, type SkillFrontmatter, type SkillInput, type SkillOutput, type SkillToolDef, type ToolCall, type ToolDef, type ToolResult, createAnthropicClient, createLlmClient, createOpenAIClient, loadSkillsFromDir, parseSkillMd, validateSkillFrontmatter };
|
|
365
|
+
export { type CompletionResult, DEFAULT_MAX_TOOL_ROUNDS, DEFAULT_SCRIPT_TIMEOUT_MS, DynamicScriptSkill, type DynamicScriptSkillParams, type LlmClient, type LlmClientConfig, type LlmProvider, type LoadSkillsOptions, type LoaderLogger, MAX_SCRIPT_OUTPUT, MAX_STATIC_FILE_SIZE, type ParsedSkill, type RunScriptOptions, type RunScriptResult, ScriptSkill, type ScriptSkillLogger, type ScriptSkillParams, type Skill, type SkillContext, type SkillFrontmatter, type SkillInput, type SkillMode, type SkillOutput, type SkillToolDef, StaticFileSkill, type StaticFileSkillParams, StaticScriptSkill, type StaticScriptSkillParams, type ToolCall, type ToolDef, type ToolResult, createAnthropicClient, createLlmClient, createOpenAIClient, loadSkillsFromDir, parseSkillMd, resolveInsidePath, runScript, validateSkillFrontmatter };
|
package/dist/skills.d.ts
CHANGED
|
@@ -17,11 +17,22 @@ interface SkillOutput {
|
|
|
17
17
|
outputMime?: string;
|
|
18
18
|
}
|
|
19
19
|
interface SkillContext {
|
|
20
|
+
/** Required only when the routed skill has `mode === 'llm'`. */
|
|
20
21
|
llm?: LlmClient;
|
|
21
22
|
agentName: string;
|
|
22
23
|
agentDescription: string;
|
|
23
24
|
signal?: AbortSignal;
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* How the runtime produces a result for a job:
|
|
28
|
+
* - `llm`: feed input through Anthropic/OpenAI with the skill's system prompt (default).
|
|
29
|
+
* - `static-file`: return the contents of a fixed file. No input required.
|
|
30
|
+
* - `static-script`: spawn a script with no stdin. No input required.
|
|
31
|
+
* - `dynamic-script`: spawn a script and pipe the user's input to stdin.
|
|
32
|
+
*
|
|
33
|
+
* Static modes set `card.static = true` so the webapp hides its input box.
|
|
34
|
+
*/
|
|
35
|
+
type SkillMode = 'llm' | 'static-file' | 'static-script' | 'dynamic-script';
|
|
25
36
|
interface ToolDef {
|
|
26
37
|
name: string;
|
|
27
38
|
description: string;
|
|
@@ -61,6 +72,8 @@ interface Skill {
|
|
|
61
72
|
priceSubunits: bigint;
|
|
62
73
|
/** Asset the price is denominated in (NATIVE_SOL or USDC_SOLANA_DEVNET, etc.). */
|
|
63
74
|
asset: Asset;
|
|
75
|
+
/** Execution mode. Default 'llm' for back-compat. */
|
|
76
|
+
mode: SkillMode;
|
|
64
77
|
image?: string;
|
|
65
78
|
imageFile?: string;
|
|
66
79
|
execute(input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
|
|
@@ -77,6 +90,8 @@ declare function createAnthropicClient(config: Omit<LlmClientConfig, 'provider'>
|
|
|
77
90
|
declare function createOpenAIClient(config: Omit<LlmClientConfig, 'provider'>): LlmClient;
|
|
78
91
|
declare function createLlmClient(config: LlmClientConfig): LlmClient;
|
|
79
92
|
|
|
93
|
+
declare const MAX_SCRIPT_OUTPUT = 1000000;
|
|
94
|
+
declare const DEFAULT_SCRIPT_TIMEOUT_MS = 60000;
|
|
80
95
|
interface SkillToolDef {
|
|
81
96
|
name: string;
|
|
82
97
|
description: string;
|
|
@@ -90,6 +105,35 @@ interface SkillToolDef {
|
|
|
90
105
|
interface ScriptSkillLogger {
|
|
91
106
|
debug?(obj: Record<string, unknown>, msg?: string): void;
|
|
92
107
|
}
|
|
108
|
+
interface RunScriptOptions {
|
|
109
|
+
cwd: string;
|
|
110
|
+
/**
|
|
111
|
+
* UTF-8 string written to the child's stdin, then stdin closed.
|
|
112
|
+
* When undefined, stdin is closed immediately (EOF) so that children
|
|
113
|
+
* which read stdin do not block until `timeoutMs`.
|
|
114
|
+
*/
|
|
115
|
+
stdin?: string;
|
|
116
|
+
/** Cancel the spawn. SIGKILL is sent on abort. */
|
|
117
|
+
signal?: AbortSignal;
|
|
118
|
+
/** Hard timeout in ms. Default `DEFAULT_SCRIPT_TIMEOUT_MS`. */
|
|
119
|
+
timeoutMs?: number;
|
|
120
|
+
/** Cap on stdout/stderr capture. Default `MAX_SCRIPT_OUTPUT`. */
|
|
121
|
+
maxOutput?: number;
|
|
122
|
+
}
|
|
123
|
+
interface RunScriptResult {
|
|
124
|
+
stdout: string;
|
|
125
|
+
stderr: string;
|
|
126
|
+
/** Null when the process was killed by signal before exiting. */
|
|
127
|
+
code: number | null;
|
|
128
|
+
/** Set when spawn itself failed (ENOENT, EACCES, etc.). */
|
|
129
|
+
spawnError?: Error;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Spawn `cmd` with `args` and capture stdout/stderr. Never uses `shell: true`,
|
|
133
|
+
* so shell metacharacters in arguments are safe. Caller is responsible for
|
|
134
|
+
* checking `code === 0` / interpreting `spawnError`.
|
|
135
|
+
*/
|
|
136
|
+
declare function runScript(cmd: string, args: string[], opts: RunScriptOptions): Promise<RunScriptResult>;
|
|
93
137
|
interface ScriptSkillParams {
|
|
94
138
|
name: string;
|
|
95
139
|
description: string;
|
|
@@ -117,6 +161,7 @@ declare class ScriptSkill implements Skill {
|
|
|
117
161
|
capabilities: string[];
|
|
118
162
|
priceSubunits: bigint;
|
|
119
163
|
asset: Asset;
|
|
164
|
+
mode: SkillMode;
|
|
120
165
|
image?: string;
|
|
121
166
|
imageFile?: string;
|
|
122
167
|
private skillDir;
|
|
@@ -129,6 +174,122 @@ declare class ScriptSkill implements Skill {
|
|
|
129
174
|
private runTool;
|
|
130
175
|
}
|
|
131
176
|
|
|
177
|
+
/** Hard ceiling on result size for static-file skills. NIP-90 result events
|
|
178
|
+
* travel through relays that may reject very large payloads; cap at 256 KB
|
|
179
|
+
* of UTF-8. Larger files should use a script that streams to an external host. */
|
|
180
|
+
declare const MAX_STATIC_FILE_SIZE: number;
|
|
181
|
+
interface StaticFileSkillParams {
|
|
182
|
+
name: string;
|
|
183
|
+
description: string;
|
|
184
|
+
capabilities: string[];
|
|
185
|
+
priceSubunits: bigint;
|
|
186
|
+
asset: Asset;
|
|
187
|
+
/** Absolute path to the file whose contents are returned on each job. */
|
|
188
|
+
outputFilePath: string;
|
|
189
|
+
image?: string;
|
|
190
|
+
imageFile?: string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Returns the contents of a fixed file as the job result. Reads on every
|
|
194
|
+
* `execute()` so authors can edit the file without restarting the agent.
|
|
195
|
+
*/
|
|
196
|
+
declare class StaticFileSkill implements Skill {
|
|
197
|
+
name: string;
|
|
198
|
+
description: string;
|
|
199
|
+
capabilities: string[];
|
|
200
|
+
priceSubunits: bigint;
|
|
201
|
+
asset: Asset;
|
|
202
|
+
mode: SkillMode;
|
|
203
|
+
image?: string;
|
|
204
|
+
imageFile?: string;
|
|
205
|
+
private outputFilePath;
|
|
206
|
+
constructor(params: StaticFileSkillParams);
|
|
207
|
+
execute(_input: SkillInput, _ctx: SkillContext): Promise<SkillOutput>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface StaticScriptSkillParams {
|
|
211
|
+
name: string;
|
|
212
|
+
description: string;
|
|
213
|
+
capabilities: string[];
|
|
214
|
+
priceSubunits: bigint;
|
|
215
|
+
asset: Asset;
|
|
216
|
+
/** Absolute path to the script. */
|
|
217
|
+
scriptPath: string;
|
|
218
|
+
/** Extra args appended after the script path. */
|
|
219
|
+
scriptArgs: string[];
|
|
220
|
+
/** Optional override of the default 60s timeout. */
|
|
221
|
+
scriptTimeoutMs?: number;
|
|
222
|
+
image?: string;
|
|
223
|
+
imageFile?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Spawns a configured script with no stdin and returns its trimmed stdout.
|
|
227
|
+
* Throws on non-zero exit so the runtime surfaces a sanitized error.
|
|
228
|
+
* The script runs with cwd set to its containing directory so relative
|
|
229
|
+
* paths inside the script behave intuitively.
|
|
230
|
+
*/
|
|
231
|
+
declare class StaticScriptSkill implements Skill {
|
|
232
|
+
name: string;
|
|
233
|
+
description: string;
|
|
234
|
+
capabilities: string[];
|
|
235
|
+
priceSubunits: bigint;
|
|
236
|
+
asset: Asset;
|
|
237
|
+
mode: SkillMode;
|
|
238
|
+
image?: string;
|
|
239
|
+
imageFile?: string;
|
|
240
|
+
private scriptPath;
|
|
241
|
+
private scriptArgs;
|
|
242
|
+
private scriptTimeoutMs?;
|
|
243
|
+
constructor(params: StaticScriptSkillParams);
|
|
244
|
+
execute(_input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface DynamicScriptSkillParams {
|
|
248
|
+
name: string;
|
|
249
|
+
description: string;
|
|
250
|
+
capabilities: string[];
|
|
251
|
+
priceSubunits: bigint;
|
|
252
|
+
asset: Asset;
|
|
253
|
+
/** Absolute path to the script. */
|
|
254
|
+
scriptPath: string;
|
|
255
|
+
/** Extra args appended after the script path. */
|
|
256
|
+
scriptArgs: string[];
|
|
257
|
+
/** Optional override of the default 60s timeout. */
|
|
258
|
+
scriptTimeoutMs?: number;
|
|
259
|
+
image?: string;
|
|
260
|
+
imageFile?: string;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Pipes the user's job input to the script's stdin and returns its
|
|
264
|
+
* trimmed stdout. Enables script-backed capabilities (proxies to
|
|
265
|
+
* external models, classical NLP, custom workers) without an LLM key
|
|
266
|
+
* on the elisym side.
|
|
267
|
+
*/
|
|
268
|
+
declare class DynamicScriptSkill implements Skill {
|
|
269
|
+
name: string;
|
|
270
|
+
description: string;
|
|
271
|
+
capabilities: string[];
|
|
272
|
+
priceSubunits: bigint;
|
|
273
|
+
asset: Asset;
|
|
274
|
+
mode: SkillMode;
|
|
275
|
+
image?: string;
|
|
276
|
+
imageFile?: string;
|
|
277
|
+
private scriptPath;
|
|
278
|
+
private scriptArgs;
|
|
279
|
+
private scriptTimeoutMs?;
|
|
280
|
+
constructor(params: DynamicScriptSkillParams);
|
|
281
|
+
execute(input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Resolve `value` relative to `rootDir` and reject anything that escapes
|
|
286
|
+
* the root (`..` segments, absolute paths outside it, or the root itself).
|
|
287
|
+
*
|
|
288
|
+
* Returns the absolute path on success, or null on rejection so callers
|
|
289
|
+
* can surface a precise error message.
|
|
290
|
+
*/
|
|
291
|
+
declare function resolveInsidePath(rootDir: string, value: string): string | null;
|
|
292
|
+
|
|
132
293
|
declare const DEFAULT_MAX_TOOL_ROUNDS = 10;
|
|
133
294
|
interface SkillFrontmatter {
|
|
134
295
|
name?: unknown;
|
|
@@ -143,6 +304,16 @@ interface SkillFrontmatter {
|
|
|
143
304
|
image_file?: unknown;
|
|
144
305
|
tools?: unknown;
|
|
145
306
|
max_tool_rounds?: unknown;
|
|
307
|
+
/** Execution mode. Default 'llm'. */
|
|
308
|
+
mode?: unknown;
|
|
309
|
+
/** Required when mode === 'static-file'. Path relative to skill dir. */
|
|
310
|
+
output_file?: unknown;
|
|
311
|
+
/** Required when mode === 'static-script' | 'dynamic-script'. Path relative to skill dir. */
|
|
312
|
+
script?: unknown;
|
|
313
|
+
/** Optional positional args appended after the script. */
|
|
314
|
+
script_args?: unknown;
|
|
315
|
+
/** Optional override of `DEFAULT_SCRIPT_TIMEOUT_MS`. */
|
|
316
|
+
script_timeout_ms?: unknown;
|
|
146
317
|
}
|
|
147
318
|
interface ParsedSkill {
|
|
148
319
|
name: string;
|
|
@@ -151,11 +322,20 @@ interface ParsedSkill {
|
|
|
151
322
|
/** Price in subunits of `asset`. */
|
|
152
323
|
priceSubunits: bigint;
|
|
153
324
|
asset: Asset;
|
|
325
|
+
mode: SkillMode;
|
|
154
326
|
systemPrompt: string;
|
|
155
327
|
tools: SkillToolDef[];
|
|
156
328
|
maxToolRounds: number;
|
|
157
329
|
image?: string;
|
|
158
330
|
imageFile?: string;
|
|
331
|
+
/** Set when mode === 'static-file'. */
|
|
332
|
+
outputFile?: string;
|
|
333
|
+
/** Set when mode is a script mode. */
|
|
334
|
+
script?: string;
|
|
335
|
+
/** Empty when no script. */
|
|
336
|
+
scriptArgs: string[];
|
|
337
|
+
/** Undefined => caller uses `DEFAULT_SCRIPT_TIMEOUT_MS`. */
|
|
338
|
+
scriptTimeoutMs?: number;
|
|
159
339
|
}
|
|
160
340
|
interface LoaderLogger {
|
|
161
341
|
debug?(obj: Record<string, unknown>, msg?: string): void;
|
|
@@ -177,9 +357,9 @@ declare function parseSkillMd(content: string): {
|
|
|
177
357
|
declare function validateSkillFrontmatter(frontmatter: SkillFrontmatter, systemPrompt: string, options?: LoadSkillsOptions): ParsedSkill;
|
|
178
358
|
/**
|
|
179
359
|
* Walk `skillsDir`, load each immediate subdirectory's SKILL.md, and
|
|
180
|
-
* return constructed `
|
|
181
|
-
* skipped with a `warn` log.
|
|
360
|
+
* return constructed `Skill` instances (LLM or non-LLM depending on
|
|
361
|
+
* frontmatter `mode`). Malformed directories are skipped with a `warn` log.
|
|
182
362
|
*/
|
|
183
363
|
declare function loadSkillsFromDir(skillsDir: string, options?: LoadSkillsOptions): Skill[];
|
|
184
364
|
|
|
185
|
-
export { type CompletionResult, DEFAULT_MAX_TOOL_ROUNDS, type LlmClient, type LlmClientConfig, type LlmProvider, type LoadSkillsOptions, type LoaderLogger, type ParsedSkill, ScriptSkill, type ScriptSkillLogger, type ScriptSkillParams, type Skill, type SkillContext, type SkillFrontmatter, type SkillInput, type SkillOutput, type SkillToolDef, type ToolCall, type ToolDef, type ToolResult, createAnthropicClient, createLlmClient, createOpenAIClient, loadSkillsFromDir, parseSkillMd, validateSkillFrontmatter };
|
|
365
|
+
export { type CompletionResult, DEFAULT_MAX_TOOL_ROUNDS, DEFAULT_SCRIPT_TIMEOUT_MS, DynamicScriptSkill, type DynamicScriptSkillParams, type LlmClient, type LlmClientConfig, type LlmProvider, type LoadSkillsOptions, type LoaderLogger, MAX_SCRIPT_OUTPUT, MAX_STATIC_FILE_SIZE, type ParsedSkill, type RunScriptOptions, type RunScriptResult, ScriptSkill, type ScriptSkillLogger, type ScriptSkillParams, type Skill, type SkillContext, type SkillFrontmatter, type SkillInput, type SkillMode, type SkillOutput, type SkillToolDef, StaticFileSkill, type StaticFileSkillParams, StaticScriptSkill, type StaticScriptSkillParams, type ToolCall, type ToolDef, type ToolResult, createAnthropicClient, createLlmClient, createOpenAIClient, loadSkillsFromDir, parseSkillMd, resolveInsidePath, runScript, validateSkillFrontmatter };
|