@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.js CHANGED
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  AgentLatticeManager: () => AgentLatticeManager,
37
37
  AgentManager: () => AgentManager,
38
38
  AgentType: () => import_protocols.AgentType,
39
+ BUILTIN_SKILLS: () => BUILTIN_SKILLS,
39
40
  ChunkBuffer: () => ChunkBuffer,
40
41
  ChunkBufferLatticeManager: () => ChunkBufferLatticeManager,
41
42
  CompositeBackend: () => CompositeBackend,
@@ -72,8 +73,6 @@ __export(index_exports, {
72
73
  MemoryType: () => import_protocols2.MemoryType,
73
74
  MessageType: () => MessageType,
74
75
  MetricsServerManager: () => MetricsServerManager,
75
- MicrosandboxInstance: () => MicrosandboxInstance,
76
- MicrosandboxProvider: () => MicrosandboxProvider,
77
76
  MicrosandboxRemoteInstance: () => MicrosandboxRemoteInstance,
78
77
  MicrosandboxRemoteProvider: () => MicrosandboxRemoteProvider,
79
78
  MicrosandboxServiceClient: () => MicrosandboxServiceClient,
@@ -135,7 +134,6 @@ __export(index_exports, {
135
134
  createUnknownToolHandlerMiddleware: () => createUnknownToolHandlerMiddleware,
136
135
  createWidgetMiddleware: () => createWidgetMiddleware,
137
136
  decrypt: () => decrypt,
138
- defaultMicrosandboxConfig: () => defaultMicrosandboxConfig,
139
137
  describeCronExpression: () => describeCronExpression,
140
138
  embeddingsLatticeManager: () => embeddingsLatticeManager,
141
139
  encrypt: () => encrypt,
@@ -149,7 +147,11 @@ __export(index_exports, {
149
147
  getAgentClient: () => getAgentClient,
150
148
  getAgentConfig: () => getAgentConfig,
151
149
  getAllAgentConfigs: () => getAllAgentConfigs,
150
+ getAllBuiltInSkillMetas: () => getAllBuiltInSkillMetas,
152
151
  getAllToolDefinitions: () => getAllToolDefinitions,
152
+ getBuiltInSkillContent: () => getBuiltInSkillContent,
153
+ getBuiltInSkillMeta: () => getBuiltInSkillMeta,
154
+ getBuiltInSkillNames: () => getBuiltInSkillNames,
153
155
  getCheckpointSaver: () => getCheckpointSaver,
154
156
  getChunkBuffer: () => getChunkBuffer,
155
157
  getEmbeddingsClient: () => getEmbeddingsClient,
@@ -171,6 +173,7 @@ __export(index_exports, {
171
173
  grepMatchesFromFiles: () => grepMatchesFromFiles,
172
174
  grepSearchFiles: () => grepSearchFiles,
173
175
  hasChunkBuffer: () => hasChunkBuffer,
176
+ isBuiltInSkill: () => isBuiltInSkill,
174
177
  isUsingDefaultKey: () => isUsingDefaultKey,
175
178
  isValidCronExpression: () => isValidCronExpression,
176
179
  isValidSandboxName: () => isValidSandboxName,
@@ -5046,6 +5049,285 @@ var import_langchain40 = require("langchain");
5046
5049
  // src/tool_lattice/skill/load_skill_content.ts
5047
5050
  var import_zod43 = __toESM(require("zod"));
5048
5051
  var import_langchain41 = require("langchain");
5052
+
5053
+ // src/skill_lattice/builtinSkills.ts
5054
+ var BUILTIN_SKILLS = {
5055
+ "create-skill": `---
5056
+ name: create-skill
5057
+ 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."
5058
+ license: MIT
5059
+ metadata:
5060
+ category: meta
5061
+ version: "2.0"
5062
+ ---
5063
+
5064
+ # Skill Creator
5065
+
5066
+ 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.
5067
+
5068
+ 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.
5069
+
5070
+ ## Communicating With the User
5071
+
5072
+ Users range from deep technical experts to people who just learned what a terminal is. Pay attention to context cues:
5073
+ - "JSON" and "assertion" \u2014 only use without explanation if the user shows comfort with them
5074
+ - "evaluation" and "benchmark" \u2014 borderline, briefly define if unsure
5075
+ - When in doubt, briefly explain terms. Short parenthetical definitions are fine.
5076
+
5077
+ ---
5078
+
5079
+ ## Step 1: Capture Intent
5080
+
5081
+ 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.
5082
+
5083
+ Ask yourself:
5084
+ 1. What capability does this skill enable?
5085
+ 2. When should this skill trigger? (what user phrases, contexts, keywords)
5086
+ 3. What is the expected output or behavior?
5087
+ 4. Does it coordinate other skills (subSkills)?
5088
+
5089
+ ## Step 2: Interview and Research
5090
+
5091
+ Proactively ask questions before writing anything:
5092
+ - **Edge cases**: What unusual inputs might arise? What should happen on failure?
5093
+ - **Input/output formats**: What formats are involved (files, data, text)?
5094
+ - **Dependencies**: Are specific tools, APIs, or data sources needed?
5095
+ - **Success criteria**: How will the user know the skill is working?
5096
+
5097
+ 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.
5098
+
5099
+ ---
5100
+
5101
+ ## Step 3: Write the SKILL.md
5102
+
5103
+ ### Skill Directory Structure
5104
+
5105
+ Skills use progressive disclosure \u2014 three levels of loading:
5106
+
5107
+ \`\`\`
5108
+ skill-name/
5109
+ \u251C\u2500\u2500 SKILL.md # Required \u2014 frontmatter + markdown body
5110
+ \u2514\u2500\u2500 resources/ # Optional \u2014 bundled files
5111
+ \u251C\u2500\u2500 scripts/ # Executable code for repetitive tasks
5112
+ \u251C\u2500\u2500 references/ # Docs loaded into context as needed
5113
+ \u2514\u2500\u2500 assets/ # Files used in output (templates, icons)
5114
+ \`\`\`
5115
+
5116
+ - **Metadata** (name + description) \u2014 always in context (~100 words)
5117
+ - **SKILL.md body** \u2014 loaded when skill triggers (aim for <500 lines)
5118
+ - **Bundled resources** \u2014 loaded as needed, unlimited
5119
+
5120
+ If SKILL.md approaches 500 lines, add hierarchy with clear pointers to reference files.
5121
+
5122
+ ### File Location
5123
+
5124
+ Write the skill to: \`/root/.agents/skills/{skill-name}/SKILL.md\`
5125
+
5126
+ Resources go in: \`/root/.agents/skills/{skill-name}/resources/\`
5127
+
5128
+ ### Naming Rules
5129
+
5130
+ Skill names (also the directory name) must follow these rules:
5131
+ - 1-64 characters, lowercase letters, digits, single hyphens
5132
+ - Pattern: \`^[a-z0-9]+(-[a-z0-9]+)*$\`
5133
+ - Cannot start or end with \`-\`, cannot contain consecutive \`--\`
5134
+
5135
+ **Good**: \`pdf-processor\`, \`sql-query\`, \`code-review\`, \`data-analytics\`
5136
+ **Bad**: \`PDF-Processor\`, \`sql__query\`, \`-test\`, \`a\`
5137
+
5138
+ ### Frontmatter Reference
5139
+
5140
+ \`\`\`yaml
5141
+ ---
5142
+ name: my-skill-name # Required \u2014 kebab-case identifier
5143
+ description: ... # Required \u2014 what AND when (this drives triggering)
5144
+ license: MIT # Optional
5145
+ compatibility: node # Optional \u2014 runtime/context requirement
5146
+ metadata: # Optional \u2014 key-value tags for search/filter
5147
+ category: tools
5148
+ version: "1.0"
5149
+ subSkills: # Optional \u2014 coordinated sub-skill names
5150
+ - sub-skill-1
5151
+ ---
5152
+
5153
+ # Markdown Body
5154
+
5155
+ Instructional content for the agent.
5156
+ \`\`\`
5157
+
5158
+ ---
5159
+
5160
+ ## Writing Guide
5161
+
5162
+ ### The Description Field
5163
+
5164
+ 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.
5165
+
5166
+ Agents tend to **undertrigger** \u2014 to not use skills when they'd be useful. To combat this, make descriptions a little "pushy":
5167
+
5168
+ - Weak: "Helps with PDF files"
5169
+ - Better: "Extract text, tables, and metadata from PDF files. Use when users need to read, parse, or extract data from PDF documents."
5170
+ - 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.'"
5171
+
5172
+ Include domain-specific trigger words: file extensions, tool names, common user phrases.
5173
+
5174
+ ### Writing the Body
5175
+
5176
+ Prefer **imperative form**. Write what the agent should DO, not what the skill IS:
5177
+ - "Check the database connection and verify table schemas" \u2014 good
5178
+ - "The database connection is checked and table schemas are verified" \u2014 weak
5179
+
5180
+ **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.
5181
+
5182
+ **Use examples** to ground abstract instructions:
5183
+
5184
+ \`\`\`markdown
5185
+ ## Commit message format
5186
+ **Example 1:**
5187
+ Input: Added user authentication with JWT tokens
5188
+ Output: feat(auth): implement JWT-based authentication
5189
+ \`\`\`
5190
+
5191
+ **Define output formats** explicitly when structure matters:
5192
+
5193
+ \`\`\`markdown
5194
+ ## Report structure
5195
+ ALWAYS use this exact template:
5196
+ # [Title]
5197
+ ## Executive summary
5198
+ ## Key findings
5199
+ ## Recommendations
5200
+ \`\`\`
5201
+
5202
+ ### Body Structure Checklist
5203
+
5204
+ A well-written skill body typically includes:
5205
+ - **Role definition**: What role does the agent play when executing this skill?
5206
+ - **Workflow**: Step-by-step process in a clear sequence
5207
+ - **Guidelines**: Rules, constraints, quality standards, and the WHY behind them
5208
+ - **Scenarios**: 2-3 common scenarios with concrete examples of inputs and expected outputs
5209
+ - **Edge cases**: What to do when things go wrong, when data is missing, etc.
5210
+
5211
+ ---
5212
+
5213
+ ## Step 4: Test and Iterate
5214
+
5215
+ After writing the draft, test it:
5216
+
5217
+ 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?"
5218
+ 2. **Run the skill** against each test prompt to see what the agent produces
5219
+ 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?)
5220
+ 4. **Collect feedback**: What worked? What didn't? What surprised the user?
5221
+
5222
+ ### Improving the Skill
5223
+
5224
+ When iterating based on feedback:
5225
+
5226
+ 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.
5227
+ 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.
5228
+ 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.
5229
+ 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.
5230
+
5231
+ Repeat the test \u2192 review \u2192 improve loop until the user is satisfied.
5232
+
5233
+ ---
5234
+
5235
+ ## Step 5: Optimize the Description (Optional)
5236
+
5237
+ After the skill works well, offer to optimize the description for better triggering accuracy.
5238
+
5239
+ ### How Triggering Works
5240
+
5241
+ 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.
5242
+
5243
+ ### Optimization Approach
5244
+
5245
+ 1. Create 10-15 eval queries \u2014 a mix of should-trigger and should-not-trigger prompts
5246
+ 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
5247
+ 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
5248
+ 4. Test the description against these queries and adjust based on misfires
5249
+ 5. Show the user before/after and explain what changed
5250
+
5251
+ ---
5252
+
5253
+ ## Step 6: Package and Present
5254
+
5255
+ When the skill is ready:
5256
+ 1. Verify the SKILL.md is at \`/root/.agents/skills/{skill-name}/SKILL.md\` with correct frontmatter
5257
+ 2. Confirm all resource files are in place under \`resources/\`
5258
+ 3. Tell the user the skill is ready and available at its path
5259
+ 4. Remind them that the skill will now appear in the available skills list for any agent using the skill system
5260
+
5261
+ ## Updating Existing Skills
5262
+
5263
+ When the user wants to improve an existing skill:
5264
+ 1. Read the current SKILL.md from \`/root/.agents/skills/{skill-name}/SKILL.md\`
5265
+ 2. Understand what it currently does and where it falls short
5266
+ 3. Follow the same interview \u2192 draft \u2192 test \u2192 iterate loop
5267
+ 4. **Preserve the original name** \u2014 the directory name and \`name\` frontmatter field should stay the same
5268
+ 5. Write the updated version back to the same path
5269
+
5270
+ ---
5271
+
5272
+ ## Example Walkthrough
5273
+
5274
+ **User**: "I want a skill that helps me analyze CSV data"
5275
+
5276
+ **You** (interview):
5277
+ - "What kinds of analysis \u2014 summary stats, filtering, charting?"
5278
+ - "Are the CSVs always the same format or varied?"
5279
+ - "Should it output results as text, new CSV, or visualizations?"
5280
+
5281
+ **User**: "Mostly summary stats and filtering. The files vary but all have headers."
5282
+
5283
+ **You** (draft frontmatter):
5284
+ \`\`\`yaml
5285
+ ---
5286
+ name: csv-analyzer
5287
+ 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.
5288
+ metadata:
5289
+ category: data
5290
+ version: "1.0"
5291
+ ---
5292
+ \`\`\`
5293
+
5294
+ **You** (draft body): Write a workflow that teaches the agent to:
5295
+ 1. Inspect the CSV structure and headers
5296
+ 2. Let the user choose analysis type (summary, filter, aggregate)
5297
+ 3. Execute the analysis and present results clearly
5298
+ 4. Handle edge cases: missing headers, empty files, mixed types
5299
+
5300
+ **You** (write): Create \`/root/.agents/skills/csv-analyzer/SKILL.md\`
5301
+
5302
+ **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."
5303
+
5304
+ Then iterate based on what the user says.
5305
+ `
5306
+ };
5307
+ function getBuiltInSkillMeta(name) {
5308
+ const content = BUILTIN_SKILLS[name];
5309
+ if (!content) return null;
5310
+ try {
5311
+ const { meta } = parseSkillFrontmatter(content);
5312
+ return meta;
5313
+ } catch {
5314
+ return null;
5315
+ }
5316
+ }
5317
+ function getBuiltInSkillContent(name) {
5318
+ return BUILTIN_SKILLS[name];
5319
+ }
5320
+ function getAllBuiltInSkillMetas() {
5321
+ return Object.keys(BUILTIN_SKILLS).map((name) => getBuiltInSkillMeta(name)).filter((meta) => meta !== null);
5322
+ }
5323
+ function getBuiltInSkillNames() {
5324
+ return Object.keys(BUILTIN_SKILLS);
5325
+ }
5326
+ function isBuiltInSkill(name) {
5327
+ return name in BUILTIN_SKILLS;
5328
+ }
5329
+
5330
+ // src/tool_lattice/skill/load_skill_content.ts
5049
5331
  var LOAD_SKILL_CONTENT_DESCRIPTION = `
5050
5332
  Execute a skill within the main conversation
5051
5333
 
@@ -5086,6 +5368,11 @@ var createLoadSkillContentTool = () => {
5086
5368
  return (0, import_langchain41.tool)(
5087
5369
  async (input, _exe_config) => {
5088
5370
  try {
5371
+ const builtInContent = getBuiltInSkillContent(input.skill_name);
5372
+ if (builtInContent) {
5373
+ const { meta: meta2, body: body2 } = parseSkillFrontmatter(builtInContent);
5374
+ return buildSkillFile(meta2, body2);
5375
+ }
5089
5376
  const sandbox = await getSandboxFromExeConfig(_exe_config);
5090
5377
  const filePath = `/root/.agents/skills/${input.skill_name}/SKILL.md`;
5091
5378
  let content;
@@ -5143,6 +5430,7 @@ function createSkillMiddleware(params = {}) {
5143
5430
  createLoadSkillContentTool()
5144
5431
  ],
5145
5432
  beforeAgent: async (state, runtime) => {
5433
+ let resolvedSkills = [];
5146
5434
  try {
5147
5435
  const runConfig = runtime?.context?.runConfig || {};
5148
5436
  const manager = getSandBoxManager();
@@ -5172,13 +5460,24 @@ function createSkillMiddleware(params = {}) {
5172
5460
  }
5173
5461
  }
5174
5462
  if (readAll) {
5175
- latestSkills = allSkills;
5463
+ resolvedSkills = allSkills;
5176
5464
  } else if (skills && skills.length > 0) {
5177
- latestSkills = allSkills.filter((skill) => skills.includes(skill.id));
5465
+ resolvedSkills = allSkills.filter((skill) => skills.includes(skill.id));
5466
+ } else {
5467
+ resolvedSkills = allSkills;
5178
5468
  }
5179
5469
  } catch (error) {
5180
5470
  console.error("Error fetching skills:", error);
5181
5471
  }
5472
+ const builtinMetas = getAllBuiltInSkillMetas();
5473
+ for (const meta of builtinMetas) {
5474
+ resolvedSkills.push({
5475
+ id: meta.name,
5476
+ name: meta.name,
5477
+ description: meta.description
5478
+ });
5479
+ }
5480
+ latestSkills = resolvedSkills;
5182
5481
  },
5183
5482
  wrapModelCall: (request, handler) => {
5184
5483
  const skillsPrompt = latestSkills.filter((skill) => !!skill.name).map((skill) => `## ${skill.name}
@@ -16640,6 +16939,39 @@ var SandboxSkillStore = class {
16640
16939
  projectId: options.projectId
16641
16940
  };
16642
16941
  }
16942
+ /**
16943
+ * Build a Skill object from a built-in skill definition.
16944
+ */
16945
+ _builtInSkill(name, tenantId) {
16946
+ const content = getBuiltInSkillContent(name);
16947
+ if (!content) return null;
16948
+ const { meta } = parseSkillFrontmatter(content);
16949
+ const now = /* @__PURE__ */ new Date();
16950
+ return {
16951
+ id: meta.name || name,
16952
+ tenantId,
16953
+ name: meta.name || name,
16954
+ description: meta.description || "",
16955
+ license: meta.license,
16956
+ compatibility: meta.compatibility,
16957
+ metadata: meta.metadata || {},
16958
+ content,
16959
+ subSkills: meta.subSkills,
16960
+ createdAt: now,
16961
+ updatedAt: now
16962
+ };
16963
+ }
16964
+ /**
16965
+ * Get all built-in skills as Skill objects for a tenant.
16966
+ */
16967
+ _allBuiltInSkills(tenantId) {
16968
+ const skills = [];
16969
+ for (const name of Object.keys(BUILTIN_SKILLS)) {
16970
+ const skill = this._builtInSkill(name, tenantId);
16971
+ if (skill) skills.push(skill);
16972
+ }
16973
+ return skills;
16974
+ }
16643
16975
  /**
16644
16976
  * Get sandbox manager
16645
16977
  */
@@ -16776,17 +17108,25 @@ ${body}` : `${frontmatter}
16776
17108
  }
16777
17109
  }
16778
17110
  }
17111
+ const builtInSkills = this._allBuiltInSkills(tenantId);
17112
+ for (const bis of builtInSkills) {
17113
+ if (!skills.some((s) => s.id === bis.id)) {
17114
+ skills.push(bis);
17115
+ }
17116
+ }
16779
17117
  console.log(`[SandboxSkillStore] Loaded ${skills.length} skills for tenant ${tenantId}`);
16780
17118
  return skills.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
16781
17119
  } catch (error) {
16782
17120
  console.error(`[SandboxSkillStore] Error listing skills for tenant ${tenantId}:`, error);
16783
- return [];
17121
+ return this._allBuiltInSkills(tenantId);
16784
17122
  }
16785
17123
  }
16786
17124
  /**
16787
17125
  * Get skill by ID
16788
17126
  */
16789
17127
  async getSkillById(tenantId, id, context) {
17128
+ const builtIn = this._builtInSkill(id, tenantId);
17129
+ if (builtIn) return builtIn;
16790
17130
  return this.readSkillFile(tenantId, id, context);
16791
17131
  }
16792
17132
  /**
@@ -16794,6 +17134,11 @@ ${body}` : `${frontmatter}
16794
17134
  */
16795
17135
  async createSkill(tenantId, id, data, context) {
16796
17136
  validateSkillName(data.name);
17137
+ if (isBuiltInSkill(data.name)) {
17138
+ throw new Error(
17139
+ `Skill "${data.name}" is a built-in skill and cannot be overwritten`
17140
+ );
17141
+ }
16797
17142
  if (id !== data.name) {
16798
17143
  throw new Error(
16799
17144
  `Skill id "${id}" must equal name "${data.name}" (name is used for path addressing)`
@@ -16824,6 +17169,11 @@ ${body}` : `${frontmatter}
16824
17169
  * Update an existing skill
16825
17170
  */
16826
17171
  async updateSkill(tenantId, id, updates, context) {
17172
+ if (isBuiltInSkill(id)) {
17173
+ throw new Error(
17174
+ `Skill "${id}" is a built-in skill and cannot be modified`
17175
+ );
17176
+ }
16827
17177
  const skill = await this.readSkillFile(tenantId, id, context);
16828
17178
  if (!skill) {
16829
17179
  return null;
@@ -16866,6 +17216,11 @@ ${body}` : `${frontmatter}
16866
17216
  * Delete a skill by ID
16867
17217
  */
16868
17218
  async deleteSkill(tenantId, id, context) {
17219
+ if (isBuiltInSkill(id)) {
17220
+ throw new Error(
17221
+ `Skill "${id}" is a built-in skill and cannot be deleted`
17222
+ );
17223
+ }
16869
17224
  try {
16870
17225
  const sandbox = await this.getSandbox(tenantId, context);
16871
17226
  const dirPath = this.getSkillDirectoryPath(tenantId, id);
@@ -16885,6 +17240,7 @@ ${body}` : `${frontmatter}
16885
17240
  * Check if skill exists
16886
17241
  */
16887
17242
  async hasSkill(tenantId, id, context) {
17243
+ if (isBuiltInSkill(id)) return true;
16888
17244
  const skill = await this.getSkillById(tenantId, id, context);
16889
17245
  return skill !== null;
16890
17246
  }
@@ -18343,230 +18699,6 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
18343
18699
  };
18344
18700
  var mcpManager = McpLatticeManager.getInstance();
18345
18701
 
18346
- // src/sandbox_lattice/providers/MicrosandboxProvider.ts
18347
- var import_microsandbox = require("microsandbox");
18348
-
18349
- // src/sandbox_lattice/MicrosandboxInstance.ts
18350
- function exec(native, cmd, opts) {
18351
- return native.execWithConfig({ cmd, args: opts?.args, cwd: opts?.cwd, timeoutMs: opts?.timeoutMs });
18352
- }
18353
- var MicrosandboxInstance = class {
18354
- constructor(name, native) {
18355
- this.native = native;
18356
- this.file = {
18357
- readFile: async (file) => {
18358
- const fs3 = this.native.fs();
18359
- const content = await fs3.readString(file);
18360
- return { content };
18361
- },
18362
- writeFile: async (file, content) => {
18363
- const fs3 = this.native.fs();
18364
- await fs3.write(file, Buffer.from(content));
18365
- },
18366
- listPath: async (path3, options) => {
18367
- const fs3 = this.native.fs();
18368
- const entries = await fs3.list(path3);
18369
- const files = (entries || []).map((e) => ({
18370
- path: e.path,
18371
- is_dir: e.kind === "directory",
18372
- size: e.size,
18373
- modified_at: e.modified ? String(e.modified) : void 0
18374
- }));
18375
- return { files };
18376
- },
18377
- findFiles: async (path3, glob) => {
18378
- const output = await exec(this.native, "sh", {
18379
- args: ["-c", `find "${path3}" -name "${glob}" -type f`]
18380
- });
18381
- const lines = output.stdout().split("\n").filter(Boolean);
18382
- return { files: lines };
18383
- },
18384
- searchInFile: async (file, regex) => {
18385
- const output = await exec(this.native, "grep", {
18386
- args: ["-n", "-E", regex, file]
18387
- });
18388
- const lines = output.stdout().split("\n").filter(Boolean);
18389
- const matches = [];
18390
- const line_numbers = [];
18391
- for (const line of lines) {
18392
- const colonIdx = line.indexOf(":");
18393
- if (colonIdx === -1) continue;
18394
- const num = parseInt(line.slice(0, colonIdx), 10);
18395
- const text = line.slice(colonIdx + 1);
18396
- line_numbers.push(num);
18397
- matches.push(text);
18398
- }
18399
- return { matches, line_numbers };
18400
- },
18401
- strReplaceEditor: async (params) => {
18402
- const { path: path3, old_str, new_str, replace_mode } = params;
18403
- const delim = "#";
18404
- const escapedOld = old_str.replace(new RegExp(`[\\\\${delim}]`, "g"), "\\$&").replace(/\n/g, "\\n");
18405
- const escapedNew = new_str.replace(new RegExp(`[\\\\${delim}]`, "g"), "\\$&").replace(/\n/g, "\\n");
18406
- const flag = replace_mode === "ALL" ? "g" : "";
18407
- await exec(this.native, "sh", {
18408
- args: ["-c", `sed -i 's${delim}${escapedOld}${delim}${escapedNew}${delim}${flag}' "${path3}"`]
18409
- });
18410
- },
18411
- uploadFile: async (params) => {
18412
- const fs3 = this.native.fs();
18413
- await fs3.write(params.file, params.data);
18414
- },
18415
- downloadFile: async (params) => {
18416
- const fs3 = this.native.fs();
18417
- const data = await fs3.read(params.file);
18418
- return Buffer.isBuffer(data) ? data : Buffer.from(data);
18419
- }
18420
- };
18421
- this.shell = {
18422
- execCommand: async (params) => {
18423
- const output = await exec(this.native, "sh", {
18424
- args: ["-c", params.command],
18425
- cwd: params.exec_dir,
18426
- timeoutMs: params.timeout ? params.timeout * 1e3 : void 0
18427
- });
18428
- return {
18429
- output: output.stdout(),
18430
- exit_code: output.code ?? 0
18431
- };
18432
- }
18433
- };
18434
- this.name = name;
18435
- }
18436
- async start() {
18437
- }
18438
- async stop() {
18439
- await this.native.stop();
18440
- }
18441
- async kill() {
18442
- await this.native.kill();
18443
- }
18444
- async getStatus() {
18445
- try {
18446
- await this.native.exec("echo", ["ok"]);
18447
- return "running";
18448
- } catch {
18449
- return "unknown";
18450
- }
18451
- }
18452
- };
18453
-
18454
- // src/sandbox_lattice/providers/MicrosandboxProvider.ts
18455
- var defaultMicrosandboxConfig = {
18456
- image: process.env.MICROSANDBOX_IMAGE ?? "python:3.11-slim",
18457
- cpus: Number(process.env.MICROSANDBOX_CPUS ?? "1"),
18458
- memoryMib: Number(process.env.MICROSANDBOX_MEMORY ?? "512"),
18459
- env: {
18460
- PYTHONDONTWRITEBYTECODE: "1",
18461
- PIP_NO_CACHE_DIR: "1",
18462
- ...process.env.MICROSANDBOX_EXTRA_ENV ? Object.fromEntries(
18463
- process.env.MICROSANDBOX_EXTRA_ENV.split(",").map((pair) => pair.split("="))
18464
- ) : {}
18465
- }
18466
- };
18467
- var MicrosandboxProvider = class {
18468
- constructor(config = {}) {
18469
- this.config = config;
18470
- this.instances = /* @__PURE__ */ new Map();
18471
- this.creating = /* @__PURE__ */ new Map();
18472
- }
18473
- async createSandbox(name, config) {
18474
- const existing = this.instances.get(name);
18475
- if (existing) {
18476
- return existing;
18477
- }
18478
- const inFlight = this.creating.get(name);
18479
- if (inFlight) {
18480
- return inFlight;
18481
- }
18482
- const creation = (async () => {
18483
- let native;
18484
- try {
18485
- const handle = await import_microsandbox.Sandbox.get(name);
18486
- if (handle.status === "stopped") {
18487
- native = await import_microsandbox.Sandbox.start(name);
18488
- } else if (handle.status === "running") {
18489
- native = await handle.connect();
18490
- } else if (handle.status === "crashed" || handle.status === "draining") {
18491
- await import_microsandbox.Sandbox.remove(name);
18492
- native = void 0;
18493
- } else {
18494
- throw new Error(`Unexpected sandbox status: ${handle.status}`);
18495
- }
18496
- } catch {
18497
- native = void 0;
18498
- }
18499
- if (!native) {
18500
- try {
18501
- native = await import_microsandbox.Sandbox.createDetached({
18502
- name,
18503
- image: this.config.image ?? "python:3.11-slim",
18504
- cpus: this.config.cpus ?? 1,
18505
- memoryMib: this.config.memoryMib ?? 512,
18506
- env: {
18507
- ...this.config.env,
18508
- ...buildSandboxMetadataEnv(config)
18509
- }
18510
- });
18511
- } catch (err) {
18512
- if (err instanceof Error && err.message.includes("already exists")) {
18513
- await import_microsandbox.Sandbox.remove(name);
18514
- native = await import_microsandbox.Sandbox.createDetached({
18515
- name,
18516
- image: this.config.image ?? "python:3.11-slim",
18517
- cpus: this.config.cpus ?? 1,
18518
- memoryMib: this.config.memoryMib ?? 512,
18519
- env: {
18520
- ...this.config.env,
18521
- ...buildSandboxMetadataEnv(config)
18522
- }
18523
- });
18524
- } else {
18525
- throw err;
18526
- }
18527
- }
18528
- }
18529
- const instance = new MicrosandboxInstance(name, native);
18530
- this.instances.set(name, instance);
18531
- return instance;
18532
- })();
18533
- this.creating.set(name, creation);
18534
- creation.catch(() => this.creating.delete(name)).then(() => this.creating.delete(name));
18535
- return creation;
18536
- }
18537
- async getSandbox(name) {
18538
- const instance = this.instances.get(name);
18539
- if (!instance) {
18540
- throw new Error(`Sandbox ${name} not found`);
18541
- }
18542
- return instance;
18543
- }
18544
- async stopSandbox(name) {
18545
- const instance = this.instances.get(name);
18546
- if (instance) {
18547
- try {
18548
- await instance.stop();
18549
- } catch {
18550
- }
18551
- }
18552
- }
18553
- async deleteSandbox(name) {
18554
- const instance = this.instances.get(name);
18555
- this.instances.delete(name);
18556
- if (instance) {
18557
- try {
18558
- await instance.kill();
18559
- await new Promise((r) => setTimeout(r, 200));
18560
- } catch {
18561
- }
18562
- }
18563
- await import_microsandbox.Sandbox.remove(name);
18564
- }
18565
- async listSandboxes() {
18566
- return Array.from(this.instances.values());
18567
- }
18568
- };
18569
-
18570
18702
  // src/sandbox_lattice/MicrosandboxRemoteInstance.ts
18571
18703
  var MicrosandboxRemoteInstance = class {
18572
18704
  constructor(name, client) {
@@ -19601,14 +19733,6 @@ var DaytonaProvider = class {
19601
19733
  // src/sandbox_lattice/SandboxProviderFactory.ts
19602
19734
  function createSandboxProvider(config) {
19603
19735
  switch (config.type) {
19604
- case "microsandbox": {
19605
- return new MicrosandboxProvider({
19606
- image: config.microsandboxImage ?? defaultMicrosandboxConfig.image,
19607
- cpus: config.microsandboxCpus ?? defaultMicrosandboxConfig.cpus,
19608
- memoryMib: config.microsandboxMemoryMib ?? defaultMicrosandboxConfig.memoryMib,
19609
- env: defaultMicrosandboxConfig.env
19610
- });
19611
- }
19612
19736
  case "remote": {
19613
19737
  if (!config.remoteBaseURL) {
19614
19738
  throw new Error("remoteBaseURL is required when sandbox provider type is 'remote'");
@@ -19625,8 +19749,7 @@ function createSandboxProvider(config) {
19625
19749
  baseURL: config.microsandboxServiceBaseURL,
19626
19750
  image: config.microsandboxImage,
19627
19751
  cpus: config.microsandboxCpus,
19628
- memoryMib: config.microsandboxMemoryMib,
19629
- env: defaultMicrosandboxConfig.env
19752
+ memoryMib: config.microsandboxMemoryMib
19630
19753
  });
19631
19754
  }
19632
19755
  case "e2b": {
@@ -19732,6 +19855,7 @@ function clearEncryptionKeyCache() {
19732
19855
  AgentLatticeManager,
19733
19856
  AgentManager,
19734
19857
  AgentType,
19858
+ BUILTIN_SKILLS,
19735
19859
  ChunkBuffer,
19736
19860
  ChunkBufferLatticeManager,
19737
19861
  CompositeBackend,
@@ -19768,8 +19892,6 @@ function clearEncryptionKeyCache() {
19768
19892
  MemoryType,
19769
19893
  MessageType,
19770
19894
  MetricsServerManager,
19771
- MicrosandboxInstance,
19772
- MicrosandboxProvider,
19773
19895
  MicrosandboxRemoteInstance,
19774
19896
  MicrosandboxRemoteProvider,
19775
19897
  MicrosandboxServiceClient,
@@ -19831,7 +19953,6 @@ function clearEncryptionKeyCache() {
19831
19953
  createUnknownToolHandlerMiddleware,
19832
19954
  createWidgetMiddleware,
19833
19955
  decrypt,
19834
- defaultMicrosandboxConfig,
19835
19956
  describeCronExpression,
19836
19957
  embeddingsLatticeManager,
19837
19958
  encrypt,
@@ -19845,7 +19966,11 @@ function clearEncryptionKeyCache() {
19845
19966
  getAgentClient,
19846
19967
  getAgentConfig,
19847
19968
  getAllAgentConfigs,
19969
+ getAllBuiltInSkillMetas,
19848
19970
  getAllToolDefinitions,
19971
+ getBuiltInSkillContent,
19972
+ getBuiltInSkillMeta,
19973
+ getBuiltInSkillNames,
19849
19974
  getCheckpointSaver,
19850
19975
  getChunkBuffer,
19851
19976
  getEmbeddingsClient,
@@ -19867,6 +19992,7 @@ function clearEncryptionKeyCache() {
19867
19992
  grepMatchesFromFiles,
19868
19993
  grepSearchFiles,
19869
19994
  hasChunkBuffer,
19995
+ isBuiltInSkill,
19870
19996
  isUsingDefaultKey,
19871
19997
  isValidCronExpression,
19872
19998
  isValidSandboxName,