@axiom-lattice/core 2.1.55 → 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.d.mts +57 -39
- package/dist/index.d.ts +57 -39
- package/dist/index.js +369 -243
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +365 -242
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
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
|
-
|
|
5251
|
+
resolvedSkills = allSkills;
|
|
4967
5252
|
} else if (skills && skills.length > 0) {
|
|
4968
|
-
|
|
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
|
}
|
|
@@ -18173,230 +18526,6 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
18173
18526
|
};
|
|
18174
18527
|
var mcpManager = McpLatticeManager.getInstance();
|
|
18175
18528
|
|
|
18176
|
-
// src/sandbox_lattice/providers/MicrosandboxProvider.ts
|
|
18177
|
-
import { Sandbox } from "microsandbox";
|
|
18178
|
-
|
|
18179
|
-
// src/sandbox_lattice/MicrosandboxInstance.ts
|
|
18180
|
-
function exec(native, cmd, opts) {
|
|
18181
|
-
return native.execWithConfig({ cmd, args: opts?.args, cwd: opts?.cwd, timeoutMs: opts?.timeoutMs });
|
|
18182
|
-
}
|
|
18183
|
-
var MicrosandboxInstance = class {
|
|
18184
|
-
constructor(name, native) {
|
|
18185
|
-
this.native = native;
|
|
18186
|
-
this.file = {
|
|
18187
|
-
readFile: async (file) => {
|
|
18188
|
-
const fs3 = this.native.fs();
|
|
18189
|
-
const content = await fs3.readString(file);
|
|
18190
|
-
return { content };
|
|
18191
|
-
},
|
|
18192
|
-
writeFile: async (file, content) => {
|
|
18193
|
-
const fs3 = this.native.fs();
|
|
18194
|
-
await fs3.write(file, Buffer.from(content));
|
|
18195
|
-
},
|
|
18196
|
-
listPath: async (path3, options) => {
|
|
18197
|
-
const fs3 = this.native.fs();
|
|
18198
|
-
const entries = await fs3.list(path3);
|
|
18199
|
-
const files = (entries || []).map((e) => ({
|
|
18200
|
-
path: e.path,
|
|
18201
|
-
is_dir: e.kind === "directory",
|
|
18202
|
-
size: e.size,
|
|
18203
|
-
modified_at: e.modified ? String(e.modified) : void 0
|
|
18204
|
-
}));
|
|
18205
|
-
return { files };
|
|
18206
|
-
},
|
|
18207
|
-
findFiles: async (path3, glob) => {
|
|
18208
|
-
const output = await exec(this.native, "sh", {
|
|
18209
|
-
args: ["-c", `find "${path3}" -name "${glob}" -type f`]
|
|
18210
|
-
});
|
|
18211
|
-
const lines = output.stdout().split("\n").filter(Boolean);
|
|
18212
|
-
return { files: lines };
|
|
18213
|
-
},
|
|
18214
|
-
searchInFile: async (file, regex) => {
|
|
18215
|
-
const output = await exec(this.native, "grep", {
|
|
18216
|
-
args: ["-n", "-E", regex, file]
|
|
18217
|
-
});
|
|
18218
|
-
const lines = output.stdout().split("\n").filter(Boolean);
|
|
18219
|
-
const matches = [];
|
|
18220
|
-
const line_numbers = [];
|
|
18221
|
-
for (const line of lines) {
|
|
18222
|
-
const colonIdx = line.indexOf(":");
|
|
18223
|
-
if (colonIdx === -1) continue;
|
|
18224
|
-
const num = parseInt(line.slice(0, colonIdx), 10);
|
|
18225
|
-
const text = line.slice(colonIdx + 1);
|
|
18226
|
-
line_numbers.push(num);
|
|
18227
|
-
matches.push(text);
|
|
18228
|
-
}
|
|
18229
|
-
return { matches, line_numbers };
|
|
18230
|
-
},
|
|
18231
|
-
strReplaceEditor: async (params) => {
|
|
18232
|
-
const { path: path3, old_str, new_str, replace_mode } = params;
|
|
18233
|
-
const delim = "#";
|
|
18234
|
-
const escapedOld = old_str.replace(new RegExp(`[\\\\${delim}]`, "g"), "\\$&").replace(/\n/g, "\\n");
|
|
18235
|
-
const escapedNew = new_str.replace(new RegExp(`[\\\\${delim}]`, "g"), "\\$&").replace(/\n/g, "\\n");
|
|
18236
|
-
const flag = replace_mode === "ALL" ? "g" : "";
|
|
18237
|
-
await exec(this.native, "sh", {
|
|
18238
|
-
args: ["-c", `sed -i 's${delim}${escapedOld}${delim}${escapedNew}${delim}${flag}' "${path3}"`]
|
|
18239
|
-
});
|
|
18240
|
-
},
|
|
18241
|
-
uploadFile: async (params) => {
|
|
18242
|
-
const fs3 = this.native.fs();
|
|
18243
|
-
await fs3.write(params.file, params.data);
|
|
18244
|
-
},
|
|
18245
|
-
downloadFile: async (params) => {
|
|
18246
|
-
const fs3 = this.native.fs();
|
|
18247
|
-
const data = await fs3.read(params.file);
|
|
18248
|
-
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
18249
|
-
}
|
|
18250
|
-
};
|
|
18251
|
-
this.shell = {
|
|
18252
|
-
execCommand: async (params) => {
|
|
18253
|
-
const output = await exec(this.native, "sh", {
|
|
18254
|
-
args: ["-c", params.command],
|
|
18255
|
-
cwd: params.exec_dir,
|
|
18256
|
-
timeoutMs: params.timeout ? params.timeout * 1e3 : void 0
|
|
18257
|
-
});
|
|
18258
|
-
return {
|
|
18259
|
-
output: output.stdout(),
|
|
18260
|
-
exit_code: output.code ?? 0
|
|
18261
|
-
};
|
|
18262
|
-
}
|
|
18263
|
-
};
|
|
18264
|
-
this.name = name;
|
|
18265
|
-
}
|
|
18266
|
-
async start() {
|
|
18267
|
-
}
|
|
18268
|
-
async stop() {
|
|
18269
|
-
await this.native.stop();
|
|
18270
|
-
}
|
|
18271
|
-
async kill() {
|
|
18272
|
-
await this.native.kill();
|
|
18273
|
-
}
|
|
18274
|
-
async getStatus() {
|
|
18275
|
-
try {
|
|
18276
|
-
await this.native.exec("echo", ["ok"]);
|
|
18277
|
-
return "running";
|
|
18278
|
-
} catch {
|
|
18279
|
-
return "unknown";
|
|
18280
|
-
}
|
|
18281
|
-
}
|
|
18282
|
-
};
|
|
18283
|
-
|
|
18284
|
-
// src/sandbox_lattice/providers/MicrosandboxProvider.ts
|
|
18285
|
-
var defaultMicrosandboxConfig = {
|
|
18286
|
-
image: process.env.MICROSANDBOX_IMAGE ?? "python:3.11-slim",
|
|
18287
|
-
cpus: Number(process.env.MICROSANDBOX_CPUS ?? "1"),
|
|
18288
|
-
memoryMib: Number(process.env.MICROSANDBOX_MEMORY ?? "512"),
|
|
18289
|
-
env: {
|
|
18290
|
-
PYTHONDONTWRITEBYTECODE: "1",
|
|
18291
|
-
PIP_NO_CACHE_DIR: "1",
|
|
18292
|
-
...process.env.MICROSANDBOX_EXTRA_ENV ? Object.fromEntries(
|
|
18293
|
-
process.env.MICROSANDBOX_EXTRA_ENV.split(",").map((pair) => pair.split("="))
|
|
18294
|
-
) : {}
|
|
18295
|
-
}
|
|
18296
|
-
};
|
|
18297
|
-
var MicrosandboxProvider = class {
|
|
18298
|
-
constructor(config = {}) {
|
|
18299
|
-
this.config = config;
|
|
18300
|
-
this.instances = /* @__PURE__ */ new Map();
|
|
18301
|
-
this.creating = /* @__PURE__ */ new Map();
|
|
18302
|
-
}
|
|
18303
|
-
async createSandbox(name, config) {
|
|
18304
|
-
const existing = this.instances.get(name);
|
|
18305
|
-
if (existing) {
|
|
18306
|
-
return existing;
|
|
18307
|
-
}
|
|
18308
|
-
const inFlight = this.creating.get(name);
|
|
18309
|
-
if (inFlight) {
|
|
18310
|
-
return inFlight;
|
|
18311
|
-
}
|
|
18312
|
-
const creation = (async () => {
|
|
18313
|
-
let native;
|
|
18314
|
-
try {
|
|
18315
|
-
const handle = await Sandbox.get(name);
|
|
18316
|
-
if (handle.status === "stopped") {
|
|
18317
|
-
native = await Sandbox.start(name);
|
|
18318
|
-
} else if (handle.status === "running") {
|
|
18319
|
-
native = await handle.connect();
|
|
18320
|
-
} else if (handle.status === "crashed" || handle.status === "draining") {
|
|
18321
|
-
await Sandbox.remove(name);
|
|
18322
|
-
native = void 0;
|
|
18323
|
-
} else {
|
|
18324
|
-
throw new Error(`Unexpected sandbox status: ${handle.status}`);
|
|
18325
|
-
}
|
|
18326
|
-
} catch {
|
|
18327
|
-
native = void 0;
|
|
18328
|
-
}
|
|
18329
|
-
if (!native) {
|
|
18330
|
-
try {
|
|
18331
|
-
native = await Sandbox.createDetached({
|
|
18332
|
-
name,
|
|
18333
|
-
image: this.config.image ?? "python:3.11-slim",
|
|
18334
|
-
cpus: this.config.cpus ?? 1,
|
|
18335
|
-
memoryMib: this.config.memoryMib ?? 512,
|
|
18336
|
-
env: {
|
|
18337
|
-
...this.config.env,
|
|
18338
|
-
...buildSandboxMetadataEnv(config)
|
|
18339
|
-
}
|
|
18340
|
-
});
|
|
18341
|
-
} catch (err) {
|
|
18342
|
-
if (err instanceof Error && err.message.includes("already exists")) {
|
|
18343
|
-
await Sandbox.remove(name);
|
|
18344
|
-
native = await Sandbox.createDetached({
|
|
18345
|
-
name,
|
|
18346
|
-
image: this.config.image ?? "python:3.11-slim",
|
|
18347
|
-
cpus: this.config.cpus ?? 1,
|
|
18348
|
-
memoryMib: this.config.memoryMib ?? 512,
|
|
18349
|
-
env: {
|
|
18350
|
-
...this.config.env,
|
|
18351
|
-
...buildSandboxMetadataEnv(config)
|
|
18352
|
-
}
|
|
18353
|
-
});
|
|
18354
|
-
} else {
|
|
18355
|
-
throw err;
|
|
18356
|
-
}
|
|
18357
|
-
}
|
|
18358
|
-
}
|
|
18359
|
-
const instance = new MicrosandboxInstance(name, native);
|
|
18360
|
-
this.instances.set(name, instance);
|
|
18361
|
-
return instance;
|
|
18362
|
-
})();
|
|
18363
|
-
this.creating.set(name, creation);
|
|
18364
|
-
creation.catch(() => this.creating.delete(name)).then(() => this.creating.delete(name));
|
|
18365
|
-
return creation;
|
|
18366
|
-
}
|
|
18367
|
-
async getSandbox(name) {
|
|
18368
|
-
const instance = this.instances.get(name);
|
|
18369
|
-
if (!instance) {
|
|
18370
|
-
throw new Error(`Sandbox ${name} not found`);
|
|
18371
|
-
}
|
|
18372
|
-
return instance;
|
|
18373
|
-
}
|
|
18374
|
-
async stopSandbox(name) {
|
|
18375
|
-
const instance = this.instances.get(name);
|
|
18376
|
-
if (instance) {
|
|
18377
|
-
try {
|
|
18378
|
-
await instance.stop();
|
|
18379
|
-
} catch {
|
|
18380
|
-
}
|
|
18381
|
-
}
|
|
18382
|
-
}
|
|
18383
|
-
async deleteSandbox(name) {
|
|
18384
|
-
const instance = this.instances.get(name);
|
|
18385
|
-
this.instances.delete(name);
|
|
18386
|
-
if (instance) {
|
|
18387
|
-
try {
|
|
18388
|
-
await instance.kill();
|
|
18389
|
-
await new Promise((r) => setTimeout(r, 200));
|
|
18390
|
-
} catch {
|
|
18391
|
-
}
|
|
18392
|
-
}
|
|
18393
|
-
await Sandbox.remove(name);
|
|
18394
|
-
}
|
|
18395
|
-
async listSandboxes() {
|
|
18396
|
-
return Array.from(this.instances.values());
|
|
18397
|
-
}
|
|
18398
|
-
};
|
|
18399
|
-
|
|
18400
18529
|
// src/sandbox_lattice/MicrosandboxRemoteInstance.ts
|
|
18401
18530
|
var MicrosandboxRemoteInstance = class {
|
|
18402
18531
|
constructor(name, client) {
|
|
@@ -18958,7 +19087,7 @@ var RemoteSandboxProvider = class {
|
|
|
18958
19087
|
};
|
|
18959
19088
|
|
|
18960
19089
|
// src/sandbox_lattice/providers/E2BProvider.ts
|
|
18961
|
-
import { Sandbox
|
|
19090
|
+
import { Sandbox } from "e2b";
|
|
18962
19091
|
|
|
18963
19092
|
// src/sandbox_lattice/E2BInstance.ts
|
|
18964
19093
|
var E2BInstance = class {
|
|
@@ -19079,7 +19208,7 @@ var E2BProvider = class {
|
|
|
19079
19208
|
return inFlight;
|
|
19080
19209
|
}
|
|
19081
19210
|
const creation = (async () => {
|
|
19082
|
-
const native = await
|
|
19211
|
+
const native = await Sandbox.create(
|
|
19083
19212
|
this.config.template ?? "base",
|
|
19084
19213
|
{
|
|
19085
19214
|
apiKey: this.config.apiKey,
|
|
@@ -19431,14 +19560,6 @@ var DaytonaProvider = class {
|
|
|
19431
19560
|
// src/sandbox_lattice/SandboxProviderFactory.ts
|
|
19432
19561
|
function createSandboxProvider(config) {
|
|
19433
19562
|
switch (config.type) {
|
|
19434
|
-
case "microsandbox": {
|
|
19435
|
-
return new MicrosandboxProvider({
|
|
19436
|
-
image: config.microsandboxImage ?? defaultMicrosandboxConfig.image,
|
|
19437
|
-
cpus: config.microsandboxCpus ?? defaultMicrosandboxConfig.cpus,
|
|
19438
|
-
memoryMib: config.microsandboxMemoryMib ?? defaultMicrosandboxConfig.memoryMib,
|
|
19439
|
-
env: defaultMicrosandboxConfig.env
|
|
19440
|
-
});
|
|
19441
|
-
}
|
|
19442
19563
|
case "remote": {
|
|
19443
19564
|
if (!config.remoteBaseURL) {
|
|
19444
19565
|
throw new Error("remoteBaseURL is required when sandbox provider type is 'remote'");
|
|
@@ -19455,8 +19576,7 @@ function createSandboxProvider(config) {
|
|
|
19455
19576
|
baseURL: config.microsandboxServiceBaseURL,
|
|
19456
19577
|
image: config.microsandboxImage,
|
|
19457
19578
|
cpus: config.microsandboxCpus,
|
|
19458
|
-
memoryMib: config.microsandboxMemoryMib
|
|
19459
|
-
env: defaultMicrosandboxConfig.env
|
|
19579
|
+
memoryMib: config.microsandboxMemoryMib
|
|
19460
19580
|
});
|
|
19461
19581
|
}
|
|
19462
19582
|
case "e2b": {
|
|
@@ -19561,6 +19681,7 @@ export {
|
|
|
19561
19681
|
AgentLatticeManager,
|
|
19562
19682
|
AgentManager,
|
|
19563
19683
|
AgentType,
|
|
19684
|
+
BUILTIN_SKILLS,
|
|
19564
19685
|
ChunkBuffer,
|
|
19565
19686
|
ChunkBufferLatticeManager,
|
|
19566
19687
|
CompositeBackend,
|
|
@@ -19597,8 +19718,6 @@ export {
|
|
|
19597
19718
|
MemoryType,
|
|
19598
19719
|
MessageType,
|
|
19599
19720
|
MetricsServerManager,
|
|
19600
|
-
MicrosandboxInstance,
|
|
19601
|
-
MicrosandboxProvider,
|
|
19602
19721
|
MicrosandboxRemoteInstance,
|
|
19603
19722
|
MicrosandboxRemoteProvider,
|
|
19604
19723
|
MicrosandboxServiceClient,
|
|
@@ -19660,7 +19779,6 @@ export {
|
|
|
19660
19779
|
createUnknownToolHandlerMiddleware,
|
|
19661
19780
|
createWidgetMiddleware,
|
|
19662
19781
|
decrypt,
|
|
19663
|
-
defaultMicrosandboxConfig,
|
|
19664
19782
|
describeCronExpression,
|
|
19665
19783
|
embeddingsLatticeManager,
|
|
19666
19784
|
encrypt,
|
|
@@ -19674,7 +19792,11 @@ export {
|
|
|
19674
19792
|
getAgentClient,
|
|
19675
19793
|
getAgentConfig,
|
|
19676
19794
|
getAllAgentConfigs,
|
|
19795
|
+
getAllBuiltInSkillMetas,
|
|
19677
19796
|
getAllToolDefinitions,
|
|
19797
|
+
getBuiltInSkillContent,
|
|
19798
|
+
getBuiltInSkillMeta,
|
|
19799
|
+
getBuiltInSkillNames,
|
|
19678
19800
|
getCheckpointSaver,
|
|
19679
19801
|
getChunkBuffer,
|
|
19680
19802
|
getEmbeddingsClient,
|
|
@@ -19696,6 +19818,7 @@ export {
|
|
|
19696
19818
|
grepMatchesFromFiles,
|
|
19697
19819
|
grepSearchFiles,
|
|
19698
19820
|
hasChunkBuffer,
|
|
19821
|
+
isBuiltInSkill,
|
|
19699
19822
|
isUsingDefaultKey,
|
|
19700
19823
|
isValidCronExpression,
|
|
19701
19824
|
isValidSandboxName,
|