@elisym/sdk 0.15.2 → 0.17.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/dist/skills.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { A as Asset } from './assets-C-nzSYD4.js';
2
- import { S as SkillRateLimit } from './types-8vJ1I2KQ.js';
2
+ import { S as SkillRateLimit } from './types-COvV499T.js';
3
3
 
4
4
  /**
5
5
  * Shared SKILL.md runtime types. A skill is a markdown document whose
@@ -103,9 +103,13 @@ interface Skill {
103
103
  /** Execution mode. Default 'llm' for back-compat. */
104
104
  mode: SkillMode;
105
105
  /**
106
- * Optional per-skill LLM config override (only set when mode === 'llm').
107
- * Carried through from SKILL.md frontmatter so the runtime can route this
108
- * skill to a non-default model/provider/max_tokens.
106
+ * Optional per-skill LLM config / dependency.
107
+ *
108
+ * For mode 'llm', this overrides the agent default model/provider/max_tokens.
109
+ * For script modes, the (provider, model) pair declares which LLM API key
110
+ * the script depends on so the agent runtime can health-monitor it
111
+ * (startup probe + reactive markUnhealthy + lazy recovery). `max_tokens`
112
+ * is forbidden in script modes (the script controls its own limits).
109
113
  */
110
114
  llmOverride?: SkillLlmOverride;
111
115
  image?: string;
@@ -232,6 +236,13 @@ interface StaticFileSkillParams {
232
236
  outputFilePath: string;
233
237
  image?: string;
234
238
  imageFile?: string;
239
+ /**
240
+ * Declared LLM dependency. The skill itself never calls an LLM, but if
241
+ * the file is produced by an external pipeline that depends on a key,
242
+ * operators can declare the (provider, model) pair so the runtime can
243
+ * health-monitor it. Carried through from SKILL.md as-is.
244
+ */
245
+ llmOverride?: SkillLlmOverride;
235
246
  }
236
247
  /**
237
248
  * Returns the contents of a fixed file as the job result. Reads on every
@@ -246,6 +257,7 @@ declare class StaticFileSkill implements Skill {
246
257
  mode: SkillMode;
247
258
  image?: string;
248
259
  imageFile?: string;
260
+ llmOverride?: SkillLlmOverride;
249
261
  private outputFilePath;
250
262
  constructor(params: StaticFileSkillParams);
251
263
  execute(_input: SkillInput, _ctx: SkillContext): Promise<SkillOutput>;
@@ -271,6 +283,13 @@ interface StaticScriptSkillParams {
271
283
  scriptEnv?: NodeJS.ProcessEnv;
272
284
  image?: string;
273
285
  imageFile?: string;
286
+ /**
287
+ * Declared LLM dependency. The (provider, model) pair tells the runtime
288
+ * which API key the script reaches under the hood so it can be
289
+ * health-monitored. Carried through from SKILL.md as-is; the script
290
+ * itself reads the key from its environment.
291
+ */
292
+ llmOverride?: SkillLlmOverride;
274
293
  }
275
294
  /**
276
295
  * Spawns a configured script with no stdin and returns its trimmed stdout.
@@ -287,6 +306,7 @@ declare class StaticScriptSkill implements Skill {
287
306
  mode: SkillMode;
288
307
  image?: string;
289
308
  imageFile?: string;
309
+ llmOverride?: SkillLlmOverride;
290
310
  private scriptPath;
291
311
  private scriptArgs;
292
312
  private scriptTimeoutMs?;
@@ -315,6 +335,13 @@ interface DynamicScriptSkillParams {
315
335
  scriptEnv?: NodeJS.ProcessEnv;
316
336
  image?: string;
317
337
  imageFile?: string;
338
+ /**
339
+ * Declared LLM dependency. The (provider, model) pair tells the runtime
340
+ * which API key the script reaches under the hood so it can be
341
+ * health-monitored. Carried through from SKILL.md as-is; the script
342
+ * itself reads the key from its environment.
343
+ */
344
+ llmOverride?: SkillLlmOverride;
318
345
  }
319
346
  /**
320
347
  * Pipes the user's job input to the script's stdin and returns its
@@ -331,6 +358,7 @@ declare class DynamicScriptSkill implements Skill {
331
358
  mode: SkillMode;
332
359
  image?: string;
333
360
  imageFile?: string;
361
+ llmOverride?: SkillLlmOverride;
334
362
  private scriptPath;
335
363
  private scriptArgs;
336
364
  private scriptTimeoutMs?;
@@ -362,11 +390,16 @@ interface SkillFrontmatter {
362
390
  image_file?: unknown;
363
391
  tools?: unknown;
364
392
  max_tool_rounds?: unknown;
365
- /** Optional per-skill LLM provider override (e.g. 'anthropic', 'openai'). Pairs with `model`. */
393
+ /**
394
+ * LLM provider id. For `mode: 'llm'` this overrides the agent default for
395
+ * runtime LLM execution. For script modes, it declares the LLM the script
396
+ * depends on so the agent can health-monitor the API key (startup probe +
397
+ * reactive markUnhealthy + lazy recovery). Pairs with `model`.
398
+ */
366
399
  provider?: unknown;
367
- /** Optional per-skill LLM model override. Pairs with `provider`. */
400
+ /** LLM model id. Same semantics as `provider`. Must be set together with `provider`. */
368
401
  model?: unknown;
369
- /** Optional per-skill max_tokens override. Independent of provider/model. */
402
+ /** Per-skill max_tokens override. Only valid for `mode: 'llm'`. */
370
403
  max_tokens?: unknown;
371
404
  /** Execution mode. Default 'llm'. */
372
405
  mode?: unknown;
@@ -397,9 +430,13 @@ interface ParsedSkill {
397
430
  tools: SkillToolDef[];
398
431
  maxToolRounds: number;
399
432
  /**
400
- * Per-skill LLM override (only present when mode === 'llm' and the SKILL.md
401
- * declared at least one of `provider`/`model`/`max_tokens`). Parse-time
402
- * invariant: `provider` set iff `model` set.
433
+ * Per-skill LLM override / dependency. Present when SKILL.md declared at
434
+ * least one of `provider`/`model`/`max_tokens`. Parse-time invariant:
435
+ * `provider` set iff `model` set; `max_tokens` only when mode === 'llm'.
436
+ *
437
+ * For mode 'llm': the runtime uses these to construct the LLM client.
438
+ * For script modes: the (provider, model) pair declares the API key the
439
+ * script depends on so the agent can health-monitor it.
403
440
  */
404
441
  llmOverride?: SkillLlmOverride;
405
442
  image?: string;
package/dist/skills.js CHANGED
@@ -207,6 +207,7 @@ var StaticFileSkill = class {
207
207
  mode = "static-file";
208
208
  image;
209
209
  imageFile;
210
+ llmOverride;
210
211
  outputFilePath;
211
212
  constructor(params) {
212
213
  this.name = params.name;
@@ -216,6 +217,7 @@ var StaticFileSkill = class {
216
217
  this.asset = params.asset;
217
218
  this.image = params.image;
218
219
  this.imageFile = params.imageFile;
220
+ this.llmOverride = params.llmOverride;
219
221
  this.outputFilePath = params.outputFilePath;
220
222
  }
221
223
  async execute(_input, _ctx) {
@@ -228,6 +230,24 @@ var StaticFileSkill = class {
228
230
  return { data: buffer.toString("utf-8") };
229
231
  }
230
232
  };
233
+ var SCRIPT_EXIT_BILLING_EXHAUSTED = 42;
234
+
235
+ // src/llm-health/types.ts
236
+ var ScriptBillingExhaustedError = class extends Error {
237
+ exitCode;
238
+ stderr;
239
+ stdout;
240
+ constructor(exitCode, stdout, stderr) {
241
+ const detail = stderr.trim() || stdout.trim() || "(no output)";
242
+ super(`script exited with billing-exhausted code ${exitCode}: ${detail}`);
243
+ this.name = "ScriptBillingExhaustedError";
244
+ this.exitCode = exitCode;
245
+ this.stdout = stdout;
246
+ this.stderr = stderr;
247
+ }
248
+ };
249
+
250
+ // src/skills/staticScriptSkill.ts
231
251
  var StaticScriptSkill = class {
232
252
  name;
233
253
  description;
@@ -237,6 +257,7 @@ var StaticScriptSkill = class {
237
257
  mode = "static-script";
238
258
  image;
239
259
  imageFile;
260
+ llmOverride;
240
261
  scriptPath;
241
262
  scriptArgs;
242
263
  scriptTimeoutMs;
@@ -249,6 +270,7 @@ var StaticScriptSkill = class {
249
270
  this.asset = params.asset;
250
271
  this.image = params.image;
251
272
  this.imageFile = params.imageFile;
273
+ this.llmOverride = params.llmOverride;
252
274
  this.scriptPath = params.scriptPath;
253
275
  this.scriptArgs = params.scriptArgs;
254
276
  this.scriptTimeoutMs = params.scriptTimeoutMs;
@@ -264,6 +286,9 @@ var StaticScriptSkill = class {
264
286
  if (result.spawnError) {
265
287
  throw new Error(`script spawn failed: ${result.spawnError.message}`);
266
288
  }
289
+ if (result.code === SCRIPT_EXIT_BILLING_EXHAUSTED) {
290
+ throw new ScriptBillingExhaustedError(result.code, result.stdout, result.stderr);
291
+ }
267
292
  if (result.code !== 0) {
268
293
  const detail = result.stderr.trim() || result.stdout.trim() || "(no output)";
269
294
  throw new Error(`script failed (exit ${result.code}): ${detail}`);
@@ -280,6 +305,7 @@ var DynamicScriptSkill = class {
280
305
  mode = "dynamic-script";
281
306
  image;
282
307
  imageFile;
308
+ llmOverride;
283
309
  scriptPath;
284
310
  scriptArgs;
285
311
  scriptTimeoutMs;
@@ -292,6 +318,7 @@ var DynamicScriptSkill = class {
292
318
  this.asset = params.asset;
293
319
  this.image = params.image;
294
320
  this.imageFile = params.imageFile;
321
+ this.llmOverride = params.llmOverride;
295
322
  this.scriptPath = params.scriptPath;
296
323
  this.scriptArgs = params.scriptArgs;
297
324
  this.scriptTimeoutMs = params.scriptTimeoutMs;
@@ -308,6 +335,9 @@ var DynamicScriptSkill = class {
308
335
  if (result.spawnError) {
309
336
  throw new Error(`script spawn failed: ${result.spawnError.message}`);
310
337
  }
338
+ if (result.code === SCRIPT_EXIT_BILLING_EXHAUSTED) {
339
+ throw new ScriptBillingExhaustedError(result.code, result.stdout, result.stderr);
340
+ }
311
341
  if (result.code !== 0) {
312
342
  const detail = result.stderr.trim() || result.stdout.trim() || "(no output)";
313
343
  throw new Error(`script failed (exit ${result.code}): ${detail}`);
@@ -551,9 +581,9 @@ function validateLlmOverride(skillName, frontmatter, mode) {
551
581
  if (!hasProvider && !hasModel && !hasMaxTokens) {
552
582
  return void 0;
553
583
  }
554
- if (mode !== "llm") {
584
+ if (hasMaxTokens && mode !== "llm") {
555
585
  throw new Error(
556
- `SKILL.md "${skillName}": "provider"/"model"/"max_tokens" are only valid in mode 'llm' (got '${mode}')`
586
+ `SKILL.md "${skillName}": "max_tokens" is only valid in mode 'llm' (got '${mode}'). For script modes, control token limits inside the script.`
557
587
  );
558
588
  }
559
589
  if (hasProvider !== hasModel) {
@@ -810,7 +840,8 @@ function buildSkillFromParsed(parsed, skillDir, logger) {
810
840
  asset: parsed.asset,
811
841
  outputFilePath,
812
842
  image: parsed.image,
813
- imageFile: parsed.imageFile
843
+ imageFile: parsed.imageFile,
844
+ llmOverride: parsed.llmOverride
814
845
  });
815
846
  }
816
847
  case "static-script":
@@ -835,7 +866,8 @@ function buildSkillFromParsed(parsed, skillDir, logger) {
835
866
  scriptArgs: parsed.scriptArgs,
836
867
  scriptTimeoutMs: parsed.scriptTimeoutMs ?? DEFAULT_SCRIPT_TIMEOUT_MS,
837
868
  image: parsed.image,
838
- imageFile: parsed.imageFile
869
+ imageFile: parsed.imageFile,
870
+ llmOverride: parsed.llmOverride
839
871
  });
840
872
  }
841
873
  }