@axiom-lattice/core 2.1.56 → 2.1.57

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.mjs CHANGED
@@ -4837,6 +4837,285 @@ import { tool as tool38 } from "langchain";
4837
4837
  // src/tool_lattice/skill/load_skill_content.ts
4838
4838
  import z42 from "zod";
4839
4839
  import { tool as tool39 } from "langchain";
4840
+
4841
+ // src/skill_lattice/builtinSkills.ts
4842
+ var BUILTIN_SKILLS = {
4843
+ "create-skill": `---
4844
+ name: create-skill
4845
+ description: Create new skills, modify and improve existing skills. Use this skill whenever users mention creating a skill, wanting a new capability, asking to "make a skill for X", setting up automated workflows, or wanting to capture repeatable agent instructions \u2014 even if they don't use the word "skill."
4846
+ license: MIT
4847
+ metadata:
4848
+ category: meta
4849
+ version: "2.0"
4850
+ ---
4851
+
4852
+ # Skill Creator
4853
+
4854
+ This skill guides you through creating and improving agent skills. Your job is to figure out where the user is in the process and help them progress \u2014 whether they're starting from scratch, have a rough idea, or want to improve an existing skill.
4855
+
4856
+ At a high level, the process follows an iterative loop: **understand intent \u2192 interview \u2192 draft \u2192 test \u2192 review \u2192 improve \u2192 repeat** until satisfied. But always be flexible \u2014 if the user says "just vibe with me," do that instead.
4857
+
4858
+ ## Communicating With the User
4859
+
4860
+ Users range from deep technical experts to people who just learned what a terminal is. Pay attention to context cues:
4861
+ - "JSON" and "assertion" \u2014 only use without explanation if the user shows comfort with them
4862
+ - "evaluation" and "benchmark" \u2014 borderline, briefly define if unsure
4863
+ - When in doubt, briefly explain terms. Short parenthetical definitions are fine.
4864
+
4865
+ ---
4866
+
4867
+ ## Step 1: Capture Intent
4868
+
4869
+ Start by understanding what the user wants. The current conversation may already contain a workflow they want to capture (e.g., they say "turn this into a skill"). If so, extract answers from the conversation history first \u2014 the tools used, the sequence of steps, corrections made, input/output formats observed.
4870
+
4871
+ Ask yourself:
4872
+ 1. What capability does this skill enable?
4873
+ 2. When should this skill trigger? (what user phrases, contexts, keywords)
4874
+ 3. What is the expected output or behavior?
4875
+ 4. Does it coordinate other skills (subSkills)?
4876
+
4877
+ ## Step 2: Interview and Research
4878
+
4879
+ Proactively ask questions before writing anything:
4880
+ - **Edge cases**: What unusual inputs might arise? What should happen on failure?
4881
+ - **Input/output formats**: What formats are involved (files, data, text)?
4882
+ - **Dependencies**: Are specific tools, APIs, or data sources needed?
4883
+ - **Success criteria**: How will the user know the skill is working?
4884
+
4885
+ Don't start writing until you've got clear answers. If the user is vague, ask clarifying questions \u2014 you'll save time by not guessing wrong.
4886
+
4887
+ ---
4888
+
4889
+ ## Step 3: Write the SKILL.md
4890
+
4891
+ ### Skill Directory Structure
4892
+
4893
+ Skills use progressive disclosure \u2014 three levels of loading:
4894
+
4895
+ \`\`\`
4896
+ skill-name/
4897
+ \u251C\u2500\u2500 SKILL.md # Required \u2014 frontmatter + markdown body
4898
+ \u2514\u2500\u2500 resources/ # Optional \u2014 bundled files
4899
+ \u251C\u2500\u2500 scripts/ # Executable code for repetitive tasks
4900
+ \u251C\u2500\u2500 references/ # Docs loaded into context as needed
4901
+ \u2514\u2500\u2500 assets/ # Files used in output (templates, icons)
4902
+ \`\`\`
4903
+
4904
+ - **Metadata** (name + description) \u2014 always in context (~100 words)
4905
+ - **SKILL.md body** \u2014 loaded when skill triggers (aim for <500 lines)
4906
+ - **Bundled resources** \u2014 loaded as needed, unlimited
4907
+
4908
+ If SKILL.md approaches 500 lines, add hierarchy with clear pointers to reference files.
4909
+
4910
+ ### File Location
4911
+
4912
+ Write the skill to: \`/root/.agents/skills/{skill-name}/SKILL.md\`
4913
+
4914
+ Resources go in: \`/root/.agents/skills/{skill-name}/resources/\`
4915
+
4916
+ ### Naming Rules
4917
+
4918
+ Skill names (also the directory name) must follow these rules:
4919
+ - 1-64 characters, lowercase letters, digits, single hyphens
4920
+ - Pattern: \`^[a-z0-9]+(-[a-z0-9]+)*$\`
4921
+ - Cannot start or end with \`-\`, cannot contain consecutive \`--\`
4922
+
4923
+ **Good**: \`pdf-processor\`, \`sql-query\`, \`code-review\`, \`data-analytics\`
4924
+ **Bad**: \`PDF-Processor\`, \`sql__query\`, \`-test\`, \`a\`
4925
+
4926
+ ### Frontmatter Reference
4927
+
4928
+ \`\`\`yaml
4929
+ ---
4930
+ name: my-skill-name # Required \u2014 kebab-case identifier
4931
+ description: ... # Required \u2014 what AND when (this drives triggering)
4932
+ license: MIT # Optional
4933
+ compatibility: node # Optional \u2014 runtime/context requirement
4934
+ metadata: # Optional \u2014 key-value tags for search/filter
4935
+ category: tools
4936
+ version: "1.0"
4937
+ subSkills: # Optional \u2014 coordinated sub-skill names
4938
+ - sub-skill-1
4939
+ ---
4940
+
4941
+ # Markdown Body
4942
+
4943
+ Instructional content for the agent.
4944
+ \`\`\`
4945
+
4946
+ ---
4947
+
4948
+ ## Writing Guide
4949
+
4950
+ ### The Description Field
4951
+
4952
+ This is the most critical part. The description is the primary mechanism that determines whether an agent invokes your skill. Combine WHAT the skill does with specific contexts for WHEN to trigger.
4953
+
4954
+ Agents tend to **undertrigger** \u2014 to not use skills when they'd be useful. To combat this, make descriptions a little "pushy":
4955
+
4956
+ - Weak: "Helps with PDF files"
4957
+ - Better: "Extract text, tables, and metadata from PDF files. Use when users need to read, parse, or extract data from PDF documents."
4958
+ - Good: "Extract text, tables, and metadata from PDF files. Make sure to use this skill whenever the user mentions PDFs, extracting document data, or needs to read any kind of document file \u2014 even if they don't explicitly ask for 'PDF processing.'"
4959
+
4960
+ Include domain-specific trigger words: file extensions, tool names, common user phrases.
4961
+
4962
+ ### Writing the Body
4963
+
4964
+ Prefer **imperative form**. Write what the agent should DO, not what the skill IS:
4965
+ - "Check the database connection and verify table schemas" \u2014 good
4966
+ - "The database connection is checked and table schemas are verified" \u2014 weak
4967
+
4968
+ **Explain WHY**, not just what. Use theory of mind \u2014 help the model understand the reasoning behind instructions so it can generalize to novel situations. If you find yourself writing ALWAYS or NEVER in all caps, that's a yellow flag \u2014 reframe and explain the reasoning.
4969
+
4970
+ **Use examples** to ground abstract instructions:
4971
+
4972
+ \`\`\`markdown
4973
+ ## Commit message format
4974
+ **Example 1:**
4975
+ Input: Added user authentication with JWT tokens
4976
+ Output: feat(auth): implement JWT-based authentication
4977
+ \`\`\`
4978
+
4979
+ **Define output formats** explicitly when structure matters:
4980
+
4981
+ \`\`\`markdown
4982
+ ## Report structure
4983
+ ALWAYS use this exact template:
4984
+ # [Title]
4985
+ ## Executive summary
4986
+ ## Key findings
4987
+ ## Recommendations
4988
+ \`\`\`
4989
+
4990
+ ### Body Structure Checklist
4991
+
4992
+ A well-written skill body typically includes:
4993
+ - **Role definition**: What role does the agent play when executing this skill?
4994
+ - **Workflow**: Step-by-step process in a clear sequence
4995
+ - **Guidelines**: Rules, constraints, quality standards, and the WHY behind them
4996
+ - **Scenarios**: 2-3 common scenarios with concrete examples of inputs and expected outputs
4997
+ - **Edge cases**: What to do when things go wrong, when data is missing, etc.
4998
+
4999
+ ---
5000
+
5001
+ ## Step 4: Test and Iterate
5002
+
5003
+ After writing the draft, test it:
5004
+
5005
+ 1. **Create 2-3 test prompts** \u2014 the kind of thing a real user would actually say. Share them with the user: "Here are a few test cases I'd like to try. Do these look right?"
5006
+ 2. **Run the skill** against each test prompt to see what the agent produces
5007
+ 3. **Review outputs with the user**: evaluate both qualitatively (does the output look right?) and quantitatively (did it follow the workflow? use the right tools?)
5008
+ 4. **Collect feedback**: What worked? What didn't? What surprised the user?
5009
+
5010
+ ### Improving the Skill
5011
+
5012
+ When iterating based on feedback:
5013
+
5014
+ 1. **Generalize from feedback** \u2014 don't overfit to the test cases. The skill will be used across many different prompts. If a fix only helps one specific example, think bigger.
5015
+ 2. **Keep it lean** \u2014 remove instructions that aren't pulling their weight. Read the full transcripts, not just final outputs. If the skill makes the agent waste time, trim it.
5016
+ 3. **Look for repeated work** \u2014 if all test runs involved writing the same helper script, bundle that script into \`resources/scripts/\` and have the skill reference it instead.
5017
+ 4. **Explain the why** \u2014 if you're adding a constraint because of a failure, explain the context so the model understands when to apply it and when it's safe to deviate.
5018
+
5019
+ Repeat the test \u2192 review \u2192 improve loop until the user is satisfied.
5020
+
5021
+ ---
5022
+
5023
+ ## Step 5: Optimize the Description (Optional)
5024
+
5025
+ After the skill works well, offer to optimize the description for better triggering accuracy.
5026
+
5027
+ ### How Triggering Works
5028
+
5029
+ The agent sees skills as a list of name + description pairs. It decides whether to consult a skill based on that description. Important: agents only consult skills for tasks they can't easily handle on their own. Simple one-step queries may not trigger a skill even if the description matches \u2014 so make sure the description emphasizes the COMPLEX or SPECIALIZED nature of the task.
5030
+
5031
+ ### Optimization Approach
5032
+
5033
+ 1. Create 10-15 eval queries \u2014 a mix of should-trigger and should-not-trigger prompts
5034
+ 2. For **should-trigger** (6-8): different phrasings of the same intent \u2014 formal, casual, indirect. Include cases where the user doesn't explicitly name the skill but clearly needs it
5035
+ 3. For **should-not-trigger** (6-8): focus on near-misses \u2014 queries that share keywords but need something different. Don't make them obviously irrelevant
5036
+ 4. Test the description against these queries and adjust based on misfires
5037
+ 5. Show the user before/after and explain what changed
5038
+
5039
+ ---
5040
+
5041
+ ## Step 6: Package and Present
5042
+
5043
+ When the skill is ready:
5044
+ 1. Verify the SKILL.md is at \`/root/.agents/skills/{skill-name}/SKILL.md\` with correct frontmatter
5045
+ 2. Confirm all resource files are in place under \`resources/\`
5046
+ 3. Tell the user the skill is ready and available at its path
5047
+ 4. Remind them that the skill will now appear in the available skills list for any agent using the skill system
5048
+
5049
+ ## Updating Existing Skills
5050
+
5051
+ When the user wants to improve an existing skill:
5052
+ 1. Read the current SKILL.md from \`/root/.agents/skills/{skill-name}/SKILL.md\`
5053
+ 2. Understand what it currently does and where it falls short
5054
+ 3. Follow the same interview \u2192 draft \u2192 test \u2192 iterate loop
5055
+ 4. **Preserve the original name** \u2014 the directory name and \`name\` frontmatter field should stay the same
5056
+ 5. Write the updated version back to the same path
5057
+
5058
+ ---
5059
+
5060
+ ## Example Walkthrough
5061
+
5062
+ **User**: "I want a skill that helps me analyze CSV data"
5063
+
5064
+ **You** (interview):
5065
+ - "What kinds of analysis \u2014 summary stats, filtering, charting?"
5066
+ - "Are the CSVs always the same format or varied?"
5067
+ - "Should it output results as text, new CSV, or visualizations?"
5068
+
5069
+ **User**: "Mostly summary stats and filtering. The files vary but all have headers."
5070
+
5071
+ **You** (draft frontmatter):
5072
+ \`\`\`yaml
5073
+ ---
5074
+ name: csv-analyzer
5075
+ description: Analyze CSV data with statistical summaries, filtering, and aggregation. Use whenever users want to explore, summarize, or extract insights from CSV files \u2014 even if they don't say "analyze" explicitly.
5076
+ metadata:
5077
+ category: data
5078
+ version: "1.0"
5079
+ ---
5080
+ \`\`\`
5081
+
5082
+ **You** (draft body): Write a workflow that teaches the agent to:
5083
+ 1. Inspect the CSV structure and headers
5084
+ 2. Let the user choose analysis type (summary, filter, aggregate)
5085
+ 3. Execute the analysis and present results clearly
5086
+ 4. Handle edge cases: missing headers, empty files, mixed types
5087
+
5088
+ **You** (write): Create \`/root/.agents/skills/csv-analyzer/SKILL.md\`
5089
+
5090
+ **You** (test): "Here are 3 test cases \u2014 'summarize this sales CSV', 'filter rows where region is West', 'show monthly revenue trends'. Let me run these and we'll review."
5091
+
5092
+ Then iterate based on what the user says.
5093
+ `
5094
+ };
5095
+ function getBuiltInSkillMeta(name) {
5096
+ const content = BUILTIN_SKILLS[name];
5097
+ if (!content) return null;
5098
+ try {
5099
+ const { meta } = parseSkillFrontmatter(content);
5100
+ return meta;
5101
+ } catch {
5102
+ return null;
5103
+ }
5104
+ }
5105
+ function getBuiltInSkillContent(name) {
5106
+ return BUILTIN_SKILLS[name];
5107
+ }
5108
+ function getAllBuiltInSkillMetas() {
5109
+ return Object.keys(BUILTIN_SKILLS).map((name) => getBuiltInSkillMeta(name)).filter((meta) => meta !== null);
5110
+ }
5111
+ function getBuiltInSkillNames() {
5112
+ return Object.keys(BUILTIN_SKILLS);
5113
+ }
5114
+ function isBuiltInSkill(name) {
5115
+ return name in BUILTIN_SKILLS;
5116
+ }
5117
+
5118
+ // src/tool_lattice/skill/load_skill_content.ts
4840
5119
  var LOAD_SKILL_CONTENT_DESCRIPTION = `
4841
5120
  Execute a skill within the main conversation
4842
5121
 
@@ -4877,6 +5156,11 @@ var createLoadSkillContentTool = () => {
4877
5156
  return tool39(
4878
5157
  async (input, _exe_config) => {
4879
5158
  try {
5159
+ const builtInContent = getBuiltInSkillContent(input.skill_name);
5160
+ if (builtInContent) {
5161
+ const { meta: meta2, body: body2 } = parseSkillFrontmatter(builtInContent);
5162
+ return buildSkillFile(meta2, body2);
5163
+ }
4880
5164
  const sandbox = await getSandboxFromExeConfig(_exe_config);
4881
5165
  const filePath = `/root/.agents/skills/${input.skill_name}/SKILL.md`;
4882
5166
  let content;
@@ -4934,6 +5218,7 @@ function createSkillMiddleware(params = {}) {
4934
5218
  createLoadSkillContentTool()
4935
5219
  ],
4936
5220
  beforeAgent: async (state, runtime) => {
5221
+ let resolvedSkills = [];
4937
5222
  try {
4938
5223
  const runConfig = runtime?.context?.runConfig || {};
4939
5224
  const manager = getSandBoxManager();
@@ -4963,13 +5248,24 @@ function createSkillMiddleware(params = {}) {
4963
5248
  }
4964
5249
  }
4965
5250
  if (readAll) {
4966
- latestSkills = allSkills;
5251
+ resolvedSkills = allSkills;
4967
5252
  } else if (skills && skills.length > 0) {
4968
- latestSkills = allSkills.filter((skill) => skills.includes(skill.id));
5253
+ resolvedSkills = allSkills.filter((skill) => skills.includes(skill.id));
5254
+ } else {
5255
+ resolvedSkills = allSkills;
4969
5256
  }
4970
5257
  } catch (error) {
4971
5258
  console.error("Error fetching skills:", error);
4972
5259
  }
5260
+ const builtinMetas = getAllBuiltInSkillMetas();
5261
+ for (const meta of builtinMetas) {
5262
+ resolvedSkills.push({
5263
+ id: meta.name,
5264
+ name: meta.name,
5265
+ description: meta.description
5266
+ });
5267
+ }
5268
+ latestSkills = resolvedSkills;
4973
5269
  },
4974
5270
  wrapModelCall: (request, handler) => {
4975
5271
  const skillsPrompt = latestSkills.filter((skill) => !!skill.name).map((skill) => `## ${skill.name}
@@ -16468,6 +16764,39 @@ var SandboxSkillStore = class {
16468
16764
  projectId: options.projectId
16469
16765
  };
16470
16766
  }
16767
+ /**
16768
+ * Build a Skill object from a built-in skill definition.
16769
+ */
16770
+ _builtInSkill(name, tenantId) {
16771
+ const content = getBuiltInSkillContent(name);
16772
+ if (!content) return null;
16773
+ const { meta } = parseSkillFrontmatter(content);
16774
+ const now = /* @__PURE__ */ new Date();
16775
+ return {
16776
+ id: meta.name || name,
16777
+ tenantId,
16778
+ name: meta.name || name,
16779
+ description: meta.description || "",
16780
+ license: meta.license,
16781
+ compatibility: meta.compatibility,
16782
+ metadata: meta.metadata || {},
16783
+ content,
16784
+ subSkills: meta.subSkills,
16785
+ createdAt: now,
16786
+ updatedAt: now
16787
+ };
16788
+ }
16789
+ /**
16790
+ * Get all built-in skills as Skill objects for a tenant.
16791
+ */
16792
+ _allBuiltInSkills(tenantId) {
16793
+ const skills = [];
16794
+ for (const name of Object.keys(BUILTIN_SKILLS)) {
16795
+ const skill = this._builtInSkill(name, tenantId);
16796
+ if (skill) skills.push(skill);
16797
+ }
16798
+ return skills;
16799
+ }
16471
16800
  /**
16472
16801
  * Get sandbox manager
16473
16802
  */
@@ -16604,17 +16933,25 @@ ${body}` : `${frontmatter}
16604
16933
  }
16605
16934
  }
16606
16935
  }
16936
+ const builtInSkills = this._allBuiltInSkills(tenantId);
16937
+ for (const bis of builtInSkills) {
16938
+ if (!skills.some((s) => s.id === bis.id)) {
16939
+ skills.push(bis);
16940
+ }
16941
+ }
16607
16942
  console.log(`[SandboxSkillStore] Loaded ${skills.length} skills for tenant ${tenantId}`);
16608
16943
  return skills.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
16609
16944
  } catch (error) {
16610
16945
  console.error(`[SandboxSkillStore] Error listing skills for tenant ${tenantId}:`, error);
16611
- return [];
16946
+ return this._allBuiltInSkills(tenantId);
16612
16947
  }
16613
16948
  }
16614
16949
  /**
16615
16950
  * Get skill by ID
16616
16951
  */
16617
16952
  async getSkillById(tenantId, id, context) {
16953
+ const builtIn = this._builtInSkill(id, tenantId);
16954
+ if (builtIn) return builtIn;
16618
16955
  return this.readSkillFile(tenantId, id, context);
16619
16956
  }
16620
16957
  /**
@@ -16622,6 +16959,11 @@ ${body}` : `${frontmatter}
16622
16959
  */
16623
16960
  async createSkill(tenantId, id, data, context) {
16624
16961
  validateSkillName(data.name);
16962
+ if (isBuiltInSkill(data.name)) {
16963
+ throw new Error(
16964
+ `Skill "${data.name}" is a built-in skill and cannot be overwritten`
16965
+ );
16966
+ }
16625
16967
  if (id !== data.name) {
16626
16968
  throw new Error(
16627
16969
  `Skill id "${id}" must equal name "${data.name}" (name is used for path addressing)`
@@ -16652,6 +16994,11 @@ ${body}` : `${frontmatter}
16652
16994
  * Update an existing skill
16653
16995
  */
16654
16996
  async updateSkill(tenantId, id, updates, context) {
16997
+ if (isBuiltInSkill(id)) {
16998
+ throw new Error(
16999
+ `Skill "${id}" is a built-in skill and cannot be modified`
17000
+ );
17001
+ }
16655
17002
  const skill = await this.readSkillFile(tenantId, id, context);
16656
17003
  if (!skill) {
16657
17004
  return null;
@@ -16694,6 +17041,11 @@ ${body}` : `${frontmatter}
16694
17041
  * Delete a skill by ID
16695
17042
  */
16696
17043
  async deleteSkill(tenantId, id, context) {
17044
+ if (isBuiltInSkill(id)) {
17045
+ throw new Error(
17046
+ `Skill "${id}" is a built-in skill and cannot be deleted`
17047
+ );
17048
+ }
16697
17049
  try {
16698
17050
  const sandbox = await this.getSandbox(tenantId, context);
16699
17051
  const dirPath = this.getSkillDirectoryPath(tenantId, id);
@@ -16713,6 +17065,7 @@ ${body}` : `${frontmatter}
16713
17065
  * Check if skill exists
16714
17066
  */
16715
17067
  async hasSkill(tenantId, id, context) {
17068
+ if (isBuiltInSkill(id)) return true;
16716
17069
  const skill = await this.getSkillById(tenantId, id, context);
16717
17070
  return skill !== null;
16718
17071
  }
@@ -19328,6 +19681,7 @@ export {
19328
19681
  AgentLatticeManager,
19329
19682
  AgentManager,
19330
19683
  AgentType,
19684
+ BUILTIN_SKILLS,
19331
19685
  ChunkBuffer,
19332
19686
  ChunkBufferLatticeManager,
19333
19687
  CompositeBackend,
@@ -19438,7 +19792,11 @@ export {
19438
19792
  getAgentClient,
19439
19793
  getAgentConfig,
19440
19794
  getAllAgentConfigs,
19795
+ getAllBuiltInSkillMetas,
19441
19796
  getAllToolDefinitions,
19797
+ getBuiltInSkillContent,
19798
+ getBuiltInSkillMeta,
19799
+ getBuiltInSkillNames,
19442
19800
  getCheckpointSaver,
19443
19801
  getChunkBuffer,
19444
19802
  getEmbeddingsClient,
@@ -19460,6 +19818,7 @@ export {
19460
19818
  grepMatchesFromFiles,
19461
19819
  grepSearchFiles,
19462
19820
  hasChunkBuffer,
19821
+ isBuiltInSkill,
19463
19822
  isUsingDefaultKey,
19464
19823
  isValidCronExpression,
19465
19824
  isValidSandboxName,