@elisym/cli 0.11.2 → 0.11.4

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/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { readFileSync, readdirSync, statSync, renameSync, mkdirSync, writeFileSync } from 'node:fs';
3
3
  import { dirname, join, resolve, basename, relative, sep } from 'node:path';
4
4
  import { SolanaPaymentStrategy, validateAgentName, RELAYS, ElisymIdentity, formatSol, formatAssetAmount, USDC_SOLANA_DEVNET, ElisymClient, MediaService, jobRequestKind, DEFAULT_KIND_OFFSET, toDTag, DEFAULTS, makeCensor, DEFAULT_REDACT_PATHS, createSlidingWindowLimiter, getProtocolProgramId, getProtocolConfig, LIMITS, calculateProtocolFee, BoundedSet, KIND_JOB_FEEDBACK, NATIVE_SOL } from '@elisym/sdk';
5
- import { ElisymYamlSchema, resolveInHome, resolveInProject, createAgentDir, writeYaml, writeSecrets, listAgents, loadAgent, agentPaths, readMediaCache, lookupCachedUrl, newCacheEntry, writeMediaCache } from '@elisym/sdk/agent-store';
5
+ import { ElisymYamlSchema, resolveInHome, resolveInProject, createAgentDir, writeYamlInitial, writeSecrets, listAgents, loadAgent, writeYaml, agentPaths, readMediaCache, lookupCachedUrl, newCacheEntry, writeMediaCache } from '@elisym/sdk/agent-store';
6
6
  import { isAddress, createSolanaRpc, address } from '@solana/kit';
7
7
  import { generateSecretKey, getPublicKey, nip19, verifyEvent } from 'nostr-tools';
8
8
  import YAML from 'yaml';
@@ -1145,7 +1145,7 @@ async function cmdInit(nameArg, options = {}) {
1145
1145
  collectedKeys.set(yaml.llm.provider, defaultProviderKey);
1146
1146
  }
1147
1147
  const llmApiKeys = Object.fromEntries(collectedKeys);
1148
- await writeYaml(created.dir, yaml);
1148
+ await writeYamlInitial(created.dir, yaml);
1149
1149
  await writeSecrets(
1150
1150
  created.dir,
1151
1151
  {
@@ -2675,6 +2675,7 @@ var StaticScriptSkill = class {
2675
2675
  scriptPath: params.scriptPath,
2676
2676
  scriptArgs: params.scriptArgs,
2677
2677
  scriptTimeoutMs: params.scriptTimeoutMs,
2678
+ scriptEnv: params.scriptEnv,
2678
2679
  image: params.image,
2679
2680
  imageFile: params.imageFile
2680
2681
  });
@@ -2712,6 +2713,7 @@ var DynamicScriptSkill = class {
2712
2713
  scriptPath: params.scriptPath,
2713
2714
  scriptArgs: params.scriptArgs,
2714
2715
  scriptTimeoutMs: params.scriptTimeoutMs,
2716
+ scriptEnv: params.scriptEnv,
2715
2717
  image: params.image,
2716
2718
  imageFile: params.imageFile
2717
2719
  });
@@ -2787,7 +2789,7 @@ var ScriptSkill = class {
2787
2789
  };
2788
2790
 
2789
2791
  // src/skill/loader.ts
2790
- function buildCliSkill(parsed, entryPath) {
2792
+ function buildCliSkill(parsed, entryPath, scriptEnv) {
2791
2793
  let skill;
2792
2794
  switch (parsed.mode) {
2793
2795
  case "llm":
@@ -2852,6 +2854,7 @@ function buildCliSkill(parsed, entryPath) {
2852
2854
  scriptPath,
2853
2855
  scriptArgs: parsed.scriptArgs,
2854
2856
  scriptTimeoutMs: parsed.scriptTimeoutMs ?? DEFAULT_SCRIPT_TIMEOUT_MS,
2857
+ scriptEnv,
2855
2858
  image: parsed.image,
2856
2859
  imageFile: parsed.imageFile,
2857
2860
  dir: entryPath
@@ -2864,7 +2867,7 @@ function buildCliSkill(parsed, entryPath) {
2864
2867
  }
2865
2868
  return skill;
2866
2869
  }
2867
- function loadSkillsFromDir(skillsDir) {
2870
+ function loadSkillsFromDir(skillsDir, options = {}) {
2868
2871
  const skills = [];
2869
2872
  let entries;
2870
2873
  try {
@@ -2888,7 +2891,7 @@ function loadSkillsFromDir(skillsDir) {
2888
2891
  const parsed = validateSkillFrontmatter(frontmatter, systemPrompt, {
2889
2892
  allowFreeSkills: true
2890
2893
  });
2891
- skills.push(buildCliSkill(parsed, entryPath));
2894
+ skills.push(buildCliSkill(parsed, entryPath, options.scriptEnv));
2892
2895
  } catch (e) {
2893
2896
  const message = e instanceof Error ? e.message : String(e);
2894
2897
  console.warn(` ! Skipping skill "${entry}": ${message}`);
@@ -3238,9 +3241,17 @@ async function cmdStart(nameArg, options = {}) {
3238
3241
  `);
3239
3242
  }
3240
3243
  }
3244
+ const scriptEnv = { ...process.env };
3245
+ const llmKeys = loaded.secrets.llm_api_keys ?? {};
3246
+ for (const descriptor of listLlmProviders()) {
3247
+ const secretValue = llmKeys[descriptor.id];
3248
+ if (typeof secretValue === "string" && secretValue.length > 0) {
3249
+ scriptEnv[descriptor.envVar] = secretValue;
3250
+ }
3251
+ }
3241
3252
  const paths = agentPaths(loaded.dir);
3242
3253
  const skillsDir = paths.skills;
3243
- const allSkills = loadSkillsFromDir(skillsDir);
3254
+ const allSkills = loadSkillsFromDir(skillsDir, { scriptEnv });
3244
3255
  if (allSkills.length === 0) {
3245
3256
  console.error(` ! No skills found in ${skillsDir}
3246
3257
  `);