@elisym/sdk 0.14.0 → 0.15.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/skills.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { A as Asset } from './assets-C-nzSYD4.cjs';
2
+ import { S as SkillRateLimit } from './types-8vJ1I2KQ.cjs';
2
3
 
3
4
  /**
4
5
  * Shared SKILL.md runtime types. A skill is a markdown document whose
@@ -141,6 +142,12 @@ interface RunScriptOptions {
141
142
  timeoutMs?: number;
142
143
  /** Cap on stdout/stderr capture. Default `MAX_SCRIPT_OUTPUT`. */
143
144
  maxOutput?: number;
145
+ /**
146
+ * Full environment for the child. When omitted, the child inherits
147
+ * `process.env`. Caller is responsible for spreading `process.env`
148
+ * if PATH/HOME/etc. need to be preserved alongside extras.
149
+ */
150
+ env?: NodeJS.ProcessEnv;
144
151
  }
145
152
  interface RunScriptResult {
146
153
  stdout: string;
@@ -256,6 +263,12 @@ interface StaticScriptSkillParams {
256
263
  scriptArgs: string[];
257
264
  /** Optional override of the default 60s timeout. */
258
265
  scriptTimeoutMs?: number;
266
+ /**
267
+ * Full environment for the script. When omitted, the script inherits
268
+ * `process.env`. Callers (typically the CLI loader) spread `process.env`
269
+ * and add narrowly-scoped secrets like provider API keys.
270
+ */
271
+ scriptEnv?: NodeJS.ProcessEnv;
259
272
  image?: string;
260
273
  imageFile?: string;
261
274
  }
@@ -277,6 +290,7 @@ declare class StaticScriptSkill implements Skill {
277
290
  private scriptPath;
278
291
  private scriptArgs;
279
292
  private scriptTimeoutMs?;
293
+ private scriptEnv?;
280
294
  constructor(params: StaticScriptSkillParams);
281
295
  execute(_input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
282
296
  }
@@ -293,6 +307,12 @@ interface DynamicScriptSkillParams {
293
307
  scriptArgs: string[];
294
308
  /** Optional override of the default 60s timeout. */
295
309
  scriptTimeoutMs?: number;
310
+ /**
311
+ * Full environment for the script. When omitted, the script inherits
312
+ * `process.env`. Callers (typically the CLI loader) spread `process.env`
313
+ * and add narrowly-scoped secrets like provider API keys.
314
+ */
315
+ scriptEnv?: NodeJS.ProcessEnv;
296
316
  image?: string;
297
317
  imageFile?: string;
298
318
  }
@@ -314,6 +334,7 @@ declare class DynamicScriptSkill implements Skill {
314
334
  private scriptPath;
315
335
  private scriptArgs;
316
336
  private scriptTimeoutMs?;
337
+ private scriptEnv?;
317
338
  constructor(params: DynamicScriptSkillParams);
318
339
  execute(input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
319
340
  }
@@ -357,6 +378,12 @@ interface SkillFrontmatter {
357
378
  script_args?: unknown;
358
379
  /** Optional override of `DEFAULT_SCRIPT_TIMEOUT_MS`. */
359
380
  script_timeout_ms?: unknown;
381
+ /**
382
+ * Optional per-skill rate limit. Applies to any skill mode. Snake-case
383
+ * keys here match the YAML frontmatter convention; parsed into camelCase
384
+ * `rateLimit` on `ParsedSkill`.
385
+ */
386
+ rate_limit?: unknown;
360
387
  }
361
388
  interface ParsedSkill {
362
389
  name: string;
@@ -385,6 +412,8 @@ interface ParsedSkill {
385
412
  scriptArgs: string[];
386
413
  /** Undefined => caller uses `DEFAULT_SCRIPT_TIMEOUT_MS`. */
387
414
  scriptTimeoutMs?: number;
415
+ /** Optional per-skill rate limit (any mode). */
416
+ rateLimit?: SkillRateLimit;
388
417
  }
389
418
  interface LoaderLogger {
390
419
  debug?(obj: Record<string, unknown>, msg?: string): void;
@@ -411,4 +440,4 @@ declare function validateSkillFrontmatter(frontmatter: SkillFrontmatter, systemP
411
440
  */
412
441
  declare function loadSkillsFromDir(skillsDir: string, options?: LoadSkillsOptions): Skill[];
413
442
 
414
- 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 SkillLlmOverride, type SkillMode, type SkillOutput, type SkillToolDef, StaticFileSkill, type StaticFileSkillParams, StaticScriptSkill, type StaticScriptSkillParams, type ToolCall, type ToolDef, type ToolResult, loadSkillsFromDir, parseSkillMd, resolveInsidePath, runScript, validateSkillFrontmatter };
443
+ 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 SkillLlmOverride, type SkillMode, type SkillOutput, SkillRateLimit, type SkillToolDef, StaticFileSkill, type StaticFileSkillParams, StaticScriptSkill, type StaticScriptSkillParams, type ToolCall, type ToolDef, type ToolResult, loadSkillsFromDir, parseSkillMd, resolveInsidePath, runScript, validateSkillFrontmatter };
package/dist/skills.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { A as Asset } from './assets-C-nzSYD4.js';
2
+ import { S as SkillRateLimit } from './types-8vJ1I2KQ.js';
2
3
 
3
4
  /**
4
5
  * Shared SKILL.md runtime types. A skill is a markdown document whose
@@ -141,6 +142,12 @@ interface RunScriptOptions {
141
142
  timeoutMs?: number;
142
143
  /** Cap on stdout/stderr capture. Default `MAX_SCRIPT_OUTPUT`. */
143
144
  maxOutput?: number;
145
+ /**
146
+ * Full environment for the child. When omitted, the child inherits
147
+ * `process.env`. Caller is responsible for spreading `process.env`
148
+ * if PATH/HOME/etc. need to be preserved alongside extras.
149
+ */
150
+ env?: NodeJS.ProcessEnv;
144
151
  }
145
152
  interface RunScriptResult {
146
153
  stdout: string;
@@ -256,6 +263,12 @@ interface StaticScriptSkillParams {
256
263
  scriptArgs: string[];
257
264
  /** Optional override of the default 60s timeout. */
258
265
  scriptTimeoutMs?: number;
266
+ /**
267
+ * Full environment for the script. When omitted, the script inherits
268
+ * `process.env`. Callers (typically the CLI loader) spread `process.env`
269
+ * and add narrowly-scoped secrets like provider API keys.
270
+ */
271
+ scriptEnv?: NodeJS.ProcessEnv;
259
272
  image?: string;
260
273
  imageFile?: string;
261
274
  }
@@ -277,6 +290,7 @@ declare class StaticScriptSkill implements Skill {
277
290
  private scriptPath;
278
291
  private scriptArgs;
279
292
  private scriptTimeoutMs?;
293
+ private scriptEnv?;
280
294
  constructor(params: StaticScriptSkillParams);
281
295
  execute(_input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
282
296
  }
@@ -293,6 +307,12 @@ interface DynamicScriptSkillParams {
293
307
  scriptArgs: string[];
294
308
  /** Optional override of the default 60s timeout. */
295
309
  scriptTimeoutMs?: number;
310
+ /**
311
+ * Full environment for the script. When omitted, the script inherits
312
+ * `process.env`. Callers (typically the CLI loader) spread `process.env`
313
+ * and add narrowly-scoped secrets like provider API keys.
314
+ */
315
+ scriptEnv?: NodeJS.ProcessEnv;
296
316
  image?: string;
297
317
  imageFile?: string;
298
318
  }
@@ -314,6 +334,7 @@ declare class DynamicScriptSkill implements Skill {
314
334
  private scriptPath;
315
335
  private scriptArgs;
316
336
  private scriptTimeoutMs?;
337
+ private scriptEnv?;
317
338
  constructor(params: DynamicScriptSkillParams);
318
339
  execute(input: SkillInput, ctx: SkillContext): Promise<SkillOutput>;
319
340
  }
@@ -357,6 +378,12 @@ interface SkillFrontmatter {
357
378
  script_args?: unknown;
358
379
  /** Optional override of `DEFAULT_SCRIPT_TIMEOUT_MS`. */
359
380
  script_timeout_ms?: unknown;
381
+ /**
382
+ * Optional per-skill rate limit. Applies to any skill mode. Snake-case
383
+ * keys here match the YAML frontmatter convention; parsed into camelCase
384
+ * `rateLimit` on `ParsedSkill`.
385
+ */
386
+ rate_limit?: unknown;
360
387
  }
361
388
  interface ParsedSkill {
362
389
  name: string;
@@ -385,6 +412,8 @@ interface ParsedSkill {
385
412
  scriptArgs: string[];
386
413
  /** Undefined => caller uses `DEFAULT_SCRIPT_TIMEOUT_MS`. */
387
414
  scriptTimeoutMs?: number;
415
+ /** Optional per-skill rate limit (any mode). */
416
+ rateLimit?: SkillRateLimit;
388
417
  }
389
418
  interface LoaderLogger {
390
419
  debug?(obj: Record<string, unknown>, msg?: string): void;
@@ -411,4 +440,4 @@ declare function validateSkillFrontmatter(frontmatter: SkillFrontmatter, systemP
411
440
  */
412
441
  declare function loadSkillsFromDir(skillsDir: string, options?: LoadSkillsOptions): Skill[];
413
442
 
414
- 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 SkillLlmOverride, type SkillMode, type SkillOutput, type SkillToolDef, StaticFileSkill, type StaticFileSkillParams, StaticScriptSkill, type StaticScriptSkillParams, type ToolCall, type ToolDef, type ToolResult, loadSkillsFromDir, parseSkillMd, resolveInsidePath, runScript, validateSkillFrontmatter };
443
+ 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 SkillLlmOverride, type SkillMode, type SkillOutput, SkillRateLimit, type SkillToolDef, StaticFileSkill, type StaticFileSkillParams, StaticScriptSkill, type StaticScriptSkillParams, type ToolCall, type ToolDef, type ToolResult, loadSkillsFromDir, parseSkillMd, resolveInsidePath, runScript, validateSkillFrontmatter };
package/dist/skills.js CHANGED
@@ -18,7 +18,8 @@ function runScript(cmd, args, opts) {
18
18
  stdio: ["pipe", "pipe", "pipe"],
19
19
  timeout: timeoutMs,
20
20
  killSignal: "SIGKILL",
21
- signal: opts.signal
21
+ signal: opts.signal,
22
+ env: opts.env
22
23
  });
23
24
  let stdout = "";
24
25
  let stderr = "";
@@ -239,6 +240,7 @@ var StaticScriptSkill = class {
239
240
  scriptPath;
240
241
  scriptArgs;
241
242
  scriptTimeoutMs;
243
+ scriptEnv;
242
244
  constructor(params) {
243
245
  this.name = params.name;
244
246
  this.description = params.description;
@@ -250,12 +252,14 @@ var StaticScriptSkill = class {
250
252
  this.scriptPath = params.scriptPath;
251
253
  this.scriptArgs = params.scriptArgs;
252
254
  this.scriptTimeoutMs = params.scriptTimeoutMs;
255
+ this.scriptEnv = params.scriptEnv;
253
256
  }
254
257
  async execute(_input, ctx) {
255
258
  const result = await runScript(this.scriptPath, this.scriptArgs, {
256
259
  cwd: dirname(this.scriptPath),
257
260
  signal: ctx.signal,
258
- timeoutMs: this.scriptTimeoutMs
261
+ timeoutMs: this.scriptTimeoutMs,
262
+ env: this.scriptEnv
259
263
  });
260
264
  if (result.spawnError) {
261
265
  throw new Error(`script spawn failed: ${result.spawnError.message}`);
@@ -279,6 +283,7 @@ var DynamicScriptSkill = class {
279
283
  scriptPath;
280
284
  scriptArgs;
281
285
  scriptTimeoutMs;
286
+ scriptEnv;
282
287
  constructor(params) {
283
288
  this.name = params.name;
284
289
  this.description = params.description;
@@ -290,13 +295,15 @@ var DynamicScriptSkill = class {
290
295
  this.scriptPath = params.scriptPath;
291
296
  this.scriptArgs = params.scriptArgs;
292
297
  this.scriptTimeoutMs = params.scriptTimeoutMs;
298
+ this.scriptEnv = params.scriptEnv;
293
299
  }
294
300
  async execute(input, ctx) {
295
301
  const result = await runScript(this.scriptPath, this.scriptArgs, {
296
302
  cwd: dirname(this.scriptPath),
297
303
  stdin: input.data,
298
304
  signal: ctx.signal,
299
- timeoutMs: this.scriptTimeoutMs
305
+ timeoutMs: this.scriptTimeoutMs,
306
+ env: this.scriptEnv
300
307
  });
301
308
  if (result.spawnError) {
302
309
  throw new Error(`script spawn failed: ${result.spawnError.message}`);
@@ -575,6 +582,33 @@ function validateLlmOverride(skillName, frontmatter, mode) {
575
582
  }
576
583
  return override;
577
584
  }
585
+ var MAX_RATE_LIMIT_WINDOW_SECS = 86400;
586
+ var MAX_RATE_LIMIT_PER_WINDOW = 1e4;
587
+ function validateRateLimit(skillName, raw) {
588
+ if (raw === void 0 || raw === null) {
589
+ return void 0;
590
+ }
591
+ if (typeof raw !== "object") {
592
+ throw new Error(`SKILL.md "${skillName}": "rate_limit" must be an object`);
593
+ }
594
+ const record = raw;
595
+ const perWindowSecs = record.per_window_secs;
596
+ const maxPerWindow = record.max_per_window;
597
+ if (typeof perWindowSecs !== "number" || !Number.isInteger(perWindowSecs) || perWindowSecs < 1 || perWindowSecs > MAX_RATE_LIMIT_WINDOW_SECS) {
598
+ throw new Error(
599
+ `SKILL.md "${skillName}": "rate_limit.per_window_secs" must be an integer between 1 and ${MAX_RATE_LIMIT_WINDOW_SECS}`
600
+ );
601
+ }
602
+ if (typeof maxPerWindow !== "number" || !Number.isInteger(maxPerWindow) || maxPerWindow < 1 || maxPerWindow > MAX_RATE_LIMIT_PER_WINDOW) {
603
+ throw new Error(
604
+ `SKILL.md "${skillName}": "rate_limit.max_per_window" must be an integer between 1 and ${MAX_RATE_LIMIT_PER_WINDOW}`
605
+ );
606
+ }
607
+ return {
608
+ perWindowMs: perWindowSecs * 1e3,
609
+ maxPerWindow
610
+ };
611
+ }
578
612
  function validateScriptTimeoutMs(skillName, raw) {
579
613
  if (raw === void 0 || raw === null) {
580
614
  return void 0;
@@ -717,6 +751,7 @@ function validateSkillFrontmatter(frontmatter, systemPrompt, options = {}) {
717
751
  const image = typeof frontmatter.image === "string" ? frontmatter.image : void 0;
718
752
  const imageFile = typeof frontmatter.image_file === "string" ? frontmatter.image_file : void 0;
719
753
  const llmOverride = validateLlmOverride(frontmatter.name, frontmatter, mode);
754
+ const rateLimit = validateRateLimit(frontmatter.name, frontmatter.rate_limit);
720
755
  return {
721
756
  name: frontmatter.name,
722
757
  description: frontmatter.description,
@@ -733,7 +768,8 @@ function validateSkillFrontmatter(frontmatter, systemPrompt, options = {}) {
733
768
  outputFile,
734
769
  script,
735
770
  scriptArgs,
736
- scriptTimeoutMs
771
+ scriptTimeoutMs,
772
+ rateLimit
737
773
  };
738
774
  }
739
775
  function buildSkillFromParsed(parsed, skillDir, logger) {