@mastra/core 1.1.0-alpha.0 → 1.1.0-alpha.2
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/CHANGELOG.md +28 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-DXTYXWYM.cjs → chunk-4ACKGMN2.cjs} +7 -7
- package/dist/{chunk-DXTYXWYM.cjs.map → chunk-4ACKGMN2.cjs.map} +1 -1
- package/dist/{chunk-ZZCLGEMJ.js → chunk-4KQEQ4NM.js} +192 -353
- package/dist/chunk-4KQEQ4NM.js.map +1 -0
- package/dist/{chunk-6FHHT22W.cjs → chunk-4PERRFZD.cjs} +44 -44
- package/dist/{chunk-6FHHT22W.cjs.map → chunk-4PERRFZD.cjs.map} +1 -1
- package/dist/{chunk-XSRROONT.cjs → chunk-4QJBNJI4.cjs} +5 -5
- package/dist/{chunk-XSRROONT.cjs.map → chunk-4QJBNJI4.cjs.map} +1 -1
- package/dist/{chunk-QGVPEZ5T.js → chunk-BG6DCMO2.js} +20 -10
- package/dist/chunk-BG6DCMO2.js.map +1 -0
- package/dist/{chunk-REH5FX2O.js → chunk-FVVQY6UU.js} +28 -25
- package/dist/chunk-FVVQY6UU.js.map +1 -0
- package/dist/{chunk-Z3XVFOTH.js → chunk-FZZI2V2T.js} +4 -4
- package/dist/{chunk-Z3XVFOTH.js.map → chunk-FZZI2V2T.js.map} +1 -1
- package/dist/{chunk-ACEGVEZF.js → chunk-H4C5NORS.js} +66 -46
- package/dist/chunk-H4C5NORS.js.map +1 -0
- package/dist/{chunk-N2FELMHU.cjs → chunk-HR67B4UM.cjs} +57 -24
- package/dist/chunk-HR67B4UM.cjs.map +1 -0
- package/dist/{chunk-YETWOFQL.js → chunk-KPIJA2R5.js} +21 -31
- package/dist/chunk-KPIJA2R5.js.map +1 -0
- package/dist/{chunk-ETSBNSRY.cjs → chunk-MGOFRL36.cjs} +21 -11
- package/dist/chunk-MGOFRL36.cjs.map +1 -0
- package/dist/{chunk-5VWOGZLE.js → chunk-OSIE5L6N.js} +49 -16
- package/dist/chunk-OSIE5L6N.js.map +1 -0
- package/dist/{chunk-ARMHYWF5.js → chunk-OW7H7G5N.js} +4 -4
- package/dist/{chunk-ARMHYWF5.js.map → chunk-OW7H7G5N.js.map} +1 -1
- package/dist/{chunk-TV4DA7RI.cjs → chunk-RIPKI7ON.cjs} +21 -31
- package/dist/chunk-RIPKI7ON.cjs.map +1 -0
- package/dist/{chunk-WBJMSOYD.cjs → chunk-RYVRCT7Z.cjs} +192 -354
- package/dist/chunk-RYVRCT7Z.cjs.map +1 -0
- package/dist/{chunk-3CXWVB55.cjs → chunk-SLMSUZBA.cjs} +39 -36
- package/dist/{chunk-3CXWVB55.cjs.map → chunk-SLMSUZBA.cjs.map} +1 -1
- package/dist/{chunk-5BEYS33K.js → chunk-VAJRNUEF.js} +3 -3
- package/dist/{chunk-5BEYS33K.js.map → chunk-VAJRNUEF.js.map} +1 -1
- package/dist/{chunk-OZFBUMI3.cjs → chunk-VNGQXHUE.cjs} +7 -7
- package/dist/{chunk-OZFBUMI3.cjs.map → chunk-VNGQXHUE.cjs.map} +1 -1
- package/dist/{chunk-CEYA6FNF.js → chunk-YQMDMIP6.js} +3 -3
- package/dist/{chunk-CEYA6FNF.js.map → chunk-YQMDMIP6.js.map} +1 -1
- package/dist/{chunk-RFTFSXJY.cjs → chunk-YSFYUEEG.cjs} +72 -52
- package/dist/chunk-YSFYUEEG.cjs.map +1 -0
- package/dist/docs/README.md +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/SOURCE_MAP.json +271 -271
- package/dist/docs/agents/01-overview.md +2 -2
- package/dist/docs/evals/01-overview.md +5 -5
- package/dist/docs/mcp/01-overview.md +2 -2
- package/dist/docs/observability/01-overview.md +1 -1
- package/dist/docs/observability/03-overview.md +3 -3
- package/dist/docs/rag/01-overview.md +1 -1
- package/dist/docs/tools-mcp/01-mcp-overview.md +2 -2
- package/dist/docs/voice/01-overview.md +1 -1
- package/dist/docs/workflows/01-overview.md +5 -5
- package/dist/docs/workspace/01-overview.md +32 -29
- package/dist/docs/workspace/02-filesystem.md +13 -0
- package/dist/docs/workspace/03-sandbox.md +11 -4
- package/dist/docs/workspace/05-search.md +1 -1
- package/dist/docs/workspace/06-reference.md +304 -12
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +9 -9
- package/dist/llm/index.js +2 -2
- package/dist/llm/model/provider-types.generated.d.ts +7 -2
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +3 -3
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +11 -11
- package/dist/memory/index.js +1 -1
- package/dist/processors/index.cjs +40 -40
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-B3CGX3OF.js +3 -0
- package/dist/{provider-registry-4RA5NQGH.js.map → provider-registry-B3CGX3OF.js.map} +1 -1
- package/dist/provider-registry-CHV3DFFA.cjs +40 -0
- package/dist/{provider-registry-63ZEAPKK.cjs.map → provider-registry-CHV3DFFA.cjs.map} +1 -1
- package/dist/provider-registry.json +18 -8
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +16 -16
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/agents/base.d.ts +17 -23
- package/dist/storage/domains/agents/base.d.ts.map +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +101 -101
- package/dist/storage/index.js +2 -2
- package/dist/storage/types.d.ts +53 -37
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/dist/workspace/index.cjs +32 -32
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/skills/schemas.d.ts +17 -47
- package/dist/workspace/skills/schemas.d.ts.map +1 -1
- package/dist/workspace/skills/skill-source.d.ts +1 -13
- package/dist/workspace/skills/skill-source.d.ts.map +1 -1
- package/dist/workspace/skills/types.d.ts +9 -74
- package/dist/workspace/skills/types.d.ts.map +1 -1
- package/dist/workspace/skills/workspace-skills.d.ts +2 -19
- package/dist/workspace/skills/workspace-skills.d.ts.map +1 -1
- package/dist/workspace/workspace.d.ts +0 -12
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/llm/model/provider-types.generated.d.ts +7 -2
- package/dist/chunk-5VWOGZLE.js.map +0 -1
- package/dist/chunk-ACEGVEZF.js.map +0 -1
- package/dist/chunk-ETSBNSRY.cjs.map +0 -1
- package/dist/chunk-N2FELMHU.cjs.map +0 -1
- package/dist/chunk-QGVPEZ5T.js.map +0 -1
- package/dist/chunk-REH5FX2O.js.map +0 -1
- package/dist/chunk-RFTFSXJY.cjs.map +0 -1
- package/dist/chunk-TV4DA7RI.cjs.map +0 -1
- package/dist/chunk-WBJMSOYD.cjs.map +0 -1
- package/dist/chunk-YETWOFQL.js.map +0 -1
- package/dist/chunk-ZZCLGEMJ.js.map +0 -1
- package/dist/provider-registry-4RA5NQGH.js +0 -3
- package/dist/provider-registry-63ZEAPKK.cjs +0 -40
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createTool } from './chunk-IW3BNL7A.js';
|
|
2
|
-
import z, { z as z$1 } from 'zod';
|
|
3
2
|
import * as fs2 from 'fs/promises';
|
|
4
3
|
import * as nodePath from 'path';
|
|
5
4
|
import { constants } from 'fs';
|
|
@@ -9,6 +8,7 @@ import { execFileSync } from 'child_process';
|
|
|
9
8
|
import * as crypto from 'crypto';
|
|
10
9
|
import * as os from 'os';
|
|
11
10
|
import os__default from 'os';
|
|
11
|
+
import { z } from 'zod';
|
|
12
12
|
|
|
13
13
|
// src/workspace/errors.ts
|
|
14
14
|
var WorkspaceError = class extends Error {
|
|
@@ -830,6 +830,8 @@ var SearchEngine = class {
|
|
|
830
830
|
};
|
|
831
831
|
}
|
|
832
832
|
};
|
|
833
|
+
|
|
834
|
+
// src/workspace/skills/schemas.ts
|
|
833
835
|
var SKILL_LIMITS = {
|
|
834
836
|
/** Recommended max tokens for instructions */
|
|
835
837
|
MAX_INSTRUCTION_TOKENS: 5e3,
|
|
@@ -838,34 +840,77 @@ var SKILL_LIMITS = {
|
|
|
838
840
|
/** Max characters for name field */
|
|
839
841
|
MAX_NAME_LENGTH: 64,
|
|
840
842
|
/** Max characters for description field */
|
|
841
|
-
MAX_DESCRIPTION_LENGTH: 1024
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
843
|
+
MAX_DESCRIPTION_LENGTH: 1024};
|
|
844
|
+
function validateSkillName(name) {
|
|
845
|
+
const errors = [];
|
|
846
|
+
const fieldPath = "name";
|
|
847
|
+
if (typeof name !== "string") {
|
|
848
|
+
errors.push(`${fieldPath}: Expected string, received ${typeof name}`);
|
|
849
|
+
return errors;
|
|
850
|
+
}
|
|
851
|
+
if (name.length === 0) {
|
|
852
|
+
errors.push(`${fieldPath}: Skill name cannot be empty`);
|
|
853
|
+
return errors;
|
|
854
|
+
}
|
|
855
|
+
if (name.length > SKILL_LIMITS.MAX_NAME_LENGTH) {
|
|
856
|
+
errors.push(`${fieldPath}: Skill name must be ${SKILL_LIMITS.MAX_NAME_LENGTH} characters or less`);
|
|
857
|
+
}
|
|
858
|
+
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
859
|
+
errors.push(`${fieldPath}: Skill name must contain only lowercase letters, numbers, and hyphens`);
|
|
860
|
+
}
|
|
861
|
+
if (name.startsWith("-") || name.endsWith("-")) {
|
|
862
|
+
errors.push(`${fieldPath}: Skill name must not start or end with a hyphen`);
|
|
863
|
+
}
|
|
864
|
+
if (name.includes("--")) {
|
|
865
|
+
errors.push(`${fieldPath}: Skill name must not contain consecutive hyphens`);
|
|
866
|
+
}
|
|
867
|
+
return errors;
|
|
868
|
+
}
|
|
869
|
+
function validateSkillDescription(description) {
|
|
870
|
+
const errors = [];
|
|
871
|
+
const fieldPath = "description";
|
|
872
|
+
if (typeof description !== "string") {
|
|
873
|
+
errors.push(`${fieldPath}: Expected string, received ${typeof description}`);
|
|
874
|
+
return errors;
|
|
875
|
+
}
|
|
876
|
+
if (description.length === 0) {
|
|
877
|
+
errors.push(`${fieldPath}: Skill description cannot be empty`);
|
|
878
|
+
return errors;
|
|
879
|
+
}
|
|
880
|
+
if (description.length > SKILL_LIMITS.MAX_DESCRIPTION_LENGTH) {
|
|
881
|
+
errors.push(`${fieldPath}: Skill description must be ${SKILL_LIMITS.MAX_DESCRIPTION_LENGTH} characters or less`);
|
|
882
|
+
}
|
|
883
|
+
if (description.trim().length === 0) {
|
|
884
|
+
errors.push(`${fieldPath}: Skill description cannot be only whitespace`);
|
|
885
|
+
}
|
|
886
|
+
return errors;
|
|
887
|
+
}
|
|
888
|
+
function validateSkillLicense(license) {
|
|
889
|
+
const errors = [];
|
|
890
|
+
const fieldPath = "license";
|
|
891
|
+
if (license === void 0 || license === null) {
|
|
892
|
+
return errors;
|
|
893
|
+
}
|
|
894
|
+
if (typeof license !== "string") {
|
|
895
|
+
errors.push(`${fieldPath}: Expected string, received ${typeof license}`);
|
|
896
|
+
}
|
|
897
|
+
return errors;
|
|
898
|
+
}
|
|
899
|
+
function validateSkillCompatibility(_compatibility) {
|
|
900
|
+
return [];
|
|
901
|
+
}
|
|
902
|
+
function validateSkillMetadataField(metadata) {
|
|
903
|
+
const errors = [];
|
|
904
|
+
const fieldPath = "metadata";
|
|
905
|
+
if (metadata === void 0 || metadata === null) {
|
|
906
|
+
return errors;
|
|
907
|
+
}
|
|
908
|
+
if (typeof metadata !== "object" || Array.isArray(metadata)) {
|
|
909
|
+
errors.push(`${fieldPath}: Expected object, received ${Array.isArray(metadata) ? "array" : typeof metadata}`);
|
|
910
|
+
return errors;
|
|
911
|
+
}
|
|
912
|
+
return errors;
|
|
913
|
+
}
|
|
869
914
|
function estimateTokens(text) {
|
|
870
915
|
const words = text.split(/\s+/).filter(Boolean).length;
|
|
871
916
|
return Math.ceil(words * 1.3);
|
|
@@ -876,12 +921,20 @@ function countLines(text) {
|
|
|
876
921
|
function validateSkillMetadata(metadata, dirName, instructions) {
|
|
877
922
|
const errors = [];
|
|
878
923
|
const warnings = [];
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
924
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata)) {
|
|
925
|
+
errors.push(
|
|
926
|
+
`Expected object, received ${metadata === null ? "null" : Array.isArray(metadata) ? "array" : typeof metadata}`
|
|
927
|
+
);
|
|
928
|
+
return { valid: false, errors, warnings };
|
|
882
929
|
}
|
|
883
|
-
|
|
884
|
-
|
|
930
|
+
const data = metadata;
|
|
931
|
+
errors.push(...validateSkillName(data.name));
|
|
932
|
+
errors.push(...validateSkillDescription(data.description));
|
|
933
|
+
errors.push(...validateSkillLicense(data.license));
|
|
934
|
+
errors.push(...validateSkillCompatibility());
|
|
935
|
+
errors.push(...validateSkillMetadataField(data.metadata));
|
|
936
|
+
if (dirName && typeof data.name === "string" && data.name !== dirName) {
|
|
937
|
+
errors.push(`Skill name "${data.name}" must match directory name "${dirName}"`);
|
|
885
938
|
}
|
|
886
939
|
if (instructions) {
|
|
887
940
|
const lineCount = countLines(instructions);
|
|
@@ -903,11 +956,6 @@ function validateSkillMetadata(metadata, dirName, instructions) {
|
|
|
903
956
|
warnings
|
|
904
957
|
};
|
|
905
958
|
}
|
|
906
|
-
|
|
907
|
-
// src/workspace/skills/skill-source.ts
|
|
908
|
-
function isWritableSource(source) {
|
|
909
|
-
return "writeFile" in source && typeof source.writeFile === "function" && "mkdir" in source && typeof source.mkdir === "function" && "rmdir" in source && typeof source.rmdir === "function";
|
|
910
|
-
}
|
|
911
959
|
function isEnoentError(error) {
|
|
912
960
|
return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
|
|
913
961
|
}
|
|
@@ -1529,7 +1577,6 @@ var WorkspaceSkillsImpl = class {
|
|
|
1529
1577
|
#skillsResolver;
|
|
1530
1578
|
#searchEngine;
|
|
1531
1579
|
#validateOnLoad;
|
|
1532
|
-
#isWritable;
|
|
1533
1580
|
/** Map of skill name -> full skill data */
|
|
1534
1581
|
#skills = /* @__PURE__ */ new Map();
|
|
1535
1582
|
/** Whether skills have been discovered */
|
|
@@ -1545,21 +1592,6 @@ var WorkspaceSkillsImpl = class {
|
|
|
1545
1592
|
this.#skillsResolver = config.skills;
|
|
1546
1593
|
this.#searchEngine = config.searchEngine;
|
|
1547
1594
|
this.#validateOnLoad = config.validateOnLoad ?? true;
|
|
1548
|
-
this.#isWritable = isWritableSource(this.#source);
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Whether this skills instance supports write operations.
|
|
1552
|
-
* Returns true if backed by a WorkspaceFilesystem, false for read-only sources.
|
|
1553
|
-
*/
|
|
1554
|
-
get isWritable() {
|
|
1555
|
-
return this.#isWritable;
|
|
1556
|
-
}
|
|
1557
|
-
/**
|
|
1558
|
-
* Get the source as a writable source.
|
|
1559
|
-
* Only call after checking #isWritable is true.
|
|
1560
|
-
*/
|
|
1561
|
-
#getWritableSource() {
|
|
1562
|
-
return this.#source;
|
|
1563
1595
|
}
|
|
1564
1596
|
// ===========================================================================
|
|
1565
1597
|
// Discovery
|
|
@@ -1664,142 +1696,6 @@ var WorkspaceSkillsImpl = class {
|
|
|
1664
1696
|
return results;
|
|
1665
1697
|
}
|
|
1666
1698
|
// ===========================================================================
|
|
1667
|
-
// CRUD Operations
|
|
1668
|
-
// ===========================================================================
|
|
1669
|
-
async create(input) {
|
|
1670
|
-
await this.#ensureInitialized();
|
|
1671
|
-
if (!this.#isWritable) {
|
|
1672
|
-
throw new Error("Skills are read-only. Write operations require a WorkspaceFilesystem.");
|
|
1673
|
-
}
|
|
1674
|
-
const { metadata, instructions, references, scripts, assets } = input;
|
|
1675
|
-
if (this.#skills.has(metadata.name)) {
|
|
1676
|
-
throw new Error(`Skill "${metadata.name}" already exists`);
|
|
1677
|
-
}
|
|
1678
|
-
if (this.#validateOnLoad) {
|
|
1679
|
-
const validation = this.#validateSkillMetadata(metadata, metadata.name, instructions);
|
|
1680
|
-
if (!validation.valid) {
|
|
1681
|
-
throw new Error(`Invalid skill metadata:
|
|
1682
|
-
${validation.errors.join("\n")}`);
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
const skillsPath = this.#resolvedPaths[0];
|
|
1686
|
-
if (!skillsPath) {
|
|
1687
|
-
throw new Error("No skills path configured for creating skills");
|
|
1688
|
-
}
|
|
1689
|
-
const skillDir = this.#joinPath(skillsPath, metadata.name);
|
|
1690
|
-
if (await this.#source.exists(skillDir)) {
|
|
1691
|
-
throw new Error(`Directory "${skillDir}" already exists`);
|
|
1692
|
-
}
|
|
1693
|
-
const fs5 = this.#getWritableSource();
|
|
1694
|
-
await fs5.mkdir(skillDir);
|
|
1695
|
-
const skillMdContent = this.#buildSkillMd(metadata, instructions);
|
|
1696
|
-
await fs5.writeFile(this.#joinPath(skillDir, "SKILL.md"), skillMdContent);
|
|
1697
|
-
const refPaths = [];
|
|
1698
|
-
if (references && references.length > 0) {
|
|
1699
|
-
const refsDir = this.#joinPath(skillDir, "references");
|
|
1700
|
-
await fs5.mkdir(refsDir);
|
|
1701
|
-
for (const ref of references) {
|
|
1702
|
-
const safeRefPath = this.#assertRelativePath(ref.path, "reference");
|
|
1703
|
-
const refPath = this.#joinPath(refsDir, safeRefPath);
|
|
1704
|
-
await this.#ensureParentDir(refPath);
|
|
1705
|
-
await fs5.writeFile(refPath, ref.content);
|
|
1706
|
-
refPaths.push(safeRefPath);
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
const scriptPaths = [];
|
|
1710
|
-
if (scripts && scripts.length > 0) {
|
|
1711
|
-
const scriptsDir = this.#joinPath(skillDir, "scripts");
|
|
1712
|
-
await fs5.mkdir(scriptsDir);
|
|
1713
|
-
for (const script of scripts) {
|
|
1714
|
-
const safeScriptPath = this.#assertRelativePath(script.path, "script");
|
|
1715
|
-
const scriptPath = this.#joinPath(scriptsDir, safeScriptPath);
|
|
1716
|
-
await this.#ensureParentDir(scriptPath);
|
|
1717
|
-
await fs5.writeFile(scriptPath, script.content);
|
|
1718
|
-
scriptPaths.push(safeScriptPath);
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
const assetPaths = [];
|
|
1722
|
-
if (assets && assets.length > 0) {
|
|
1723
|
-
const assetsDir = this.#joinPath(skillDir, "assets");
|
|
1724
|
-
await fs5.mkdir(assetsDir);
|
|
1725
|
-
for (const asset of assets) {
|
|
1726
|
-
const safeAssetPath = this.#assertRelativePath(asset.path, "asset");
|
|
1727
|
-
const assetPath = this.#joinPath(assetsDir, safeAssetPath);
|
|
1728
|
-
await this.#ensureParentDir(assetPath);
|
|
1729
|
-
await fs5.writeFile(assetPath, asset.content);
|
|
1730
|
-
assetPaths.push(safeAssetPath);
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
const source = this.#determineSource(skillsPath);
|
|
1734
|
-
const indexableContent = await this.#buildIndexableContent(instructions, skillDir, refPaths);
|
|
1735
|
-
const skill = {
|
|
1736
|
-
...metadata,
|
|
1737
|
-
path: skillDir,
|
|
1738
|
-
instructions,
|
|
1739
|
-
source,
|
|
1740
|
-
references: refPaths,
|
|
1741
|
-
scripts: scriptPaths,
|
|
1742
|
-
assets: assetPaths,
|
|
1743
|
-
indexableContent
|
|
1744
|
-
};
|
|
1745
|
-
this.#skills.set(metadata.name, skill);
|
|
1746
|
-
await this.#indexSkill(skill);
|
|
1747
|
-
const { indexableContent: _, ...skillData } = skill;
|
|
1748
|
-
return skillData;
|
|
1749
|
-
}
|
|
1750
|
-
async update(name, input) {
|
|
1751
|
-
await this.#ensureInitialized();
|
|
1752
|
-
if (!this.#isWritable) {
|
|
1753
|
-
throw new Error("Skills are read-only. Write operations require a WorkspaceFilesystem.");
|
|
1754
|
-
}
|
|
1755
|
-
const skill = this.#skills.get(name);
|
|
1756
|
-
if (!skill) {
|
|
1757
|
-
throw new Error(`Skill "${name}" not found`);
|
|
1758
|
-
}
|
|
1759
|
-
const { metadata: updatedMetadata, instructions: updatedInstructions } = input;
|
|
1760
|
-
const newMetadata = {
|
|
1761
|
-
name: skill.name,
|
|
1762
|
-
// Name cannot be changed
|
|
1763
|
-
description: updatedMetadata?.description ?? skill.description,
|
|
1764
|
-
license: updatedMetadata?.license ?? skill.license,
|
|
1765
|
-
compatibility: updatedMetadata?.compatibility ?? skill.compatibility,
|
|
1766
|
-
metadata: updatedMetadata?.metadata ?? skill.metadata
|
|
1767
|
-
};
|
|
1768
|
-
const newInstructions = updatedInstructions ?? skill.instructions;
|
|
1769
|
-
if (this.#validateOnLoad) {
|
|
1770
|
-
const validation = this.#validateSkillMetadata(newMetadata, name, newInstructions);
|
|
1771
|
-
if (!validation.valid) {
|
|
1772
|
-
throw new Error(`Invalid skill metadata:
|
|
1773
|
-
${validation.errors.join("\n")}`);
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
const skillMdContent = this.#buildSkillMd(newMetadata, newInstructions);
|
|
1777
|
-
await this.#getWritableSource().writeFile(this.#joinPath(skill.path, "SKILL.md"), skillMdContent);
|
|
1778
|
-
const indexableContent = await this.#buildIndexableContent(newInstructions, skill.path, skill.references);
|
|
1779
|
-
const updatedSkill = {
|
|
1780
|
-
...skill,
|
|
1781
|
-
...newMetadata,
|
|
1782
|
-
instructions: newInstructions,
|
|
1783
|
-
indexableContent
|
|
1784
|
-
};
|
|
1785
|
-
this.#skills.set(name, updatedSkill);
|
|
1786
|
-
await this.#indexSkill(updatedSkill);
|
|
1787
|
-
const { indexableContent: _, ...skillData } = updatedSkill;
|
|
1788
|
-
return skillData;
|
|
1789
|
-
}
|
|
1790
|
-
async delete(name) {
|
|
1791
|
-
await this.#ensureInitialized();
|
|
1792
|
-
if (!this.#isWritable) {
|
|
1793
|
-
throw new Error("Skills are read-only. Write operations require a WorkspaceFilesystem.");
|
|
1794
|
-
}
|
|
1795
|
-
const skill = this.#skills.get(name);
|
|
1796
|
-
if (!skill) {
|
|
1797
|
-
throw new Error(`Skill "${name}" not found`);
|
|
1798
|
-
}
|
|
1799
|
-
await this.#getWritableSource().rmdir(skill.path, { recursive: true });
|
|
1800
|
-
this.#skills.delete(name);
|
|
1801
|
-
}
|
|
1802
|
-
// ===========================================================================
|
|
1803
1699
|
// Single-item Accessors
|
|
1804
1700
|
// ===========================================================================
|
|
1805
1701
|
async getReference(skillName, referencePath) {
|
|
@@ -2154,25 +2050,6 @@ ${validation.errors.join("\n")}`);
|
|
|
2154
2050
|
}
|
|
2155
2051
|
return { type: "local", projectPath: skillsPath };
|
|
2156
2052
|
}
|
|
2157
|
-
/**
|
|
2158
|
-
* Build SKILL.md content from metadata and instructions
|
|
2159
|
-
*/
|
|
2160
|
-
#buildSkillMd(metadata, instructions) {
|
|
2161
|
-
const frontmatter = {
|
|
2162
|
-
name: metadata.name,
|
|
2163
|
-
description: metadata.description
|
|
2164
|
-
};
|
|
2165
|
-
if (metadata.license) {
|
|
2166
|
-
frontmatter.license = metadata.license;
|
|
2167
|
-
}
|
|
2168
|
-
if (metadata.compatibility) {
|
|
2169
|
-
frontmatter.compatibility = metadata.compatibility;
|
|
2170
|
-
}
|
|
2171
|
-
if (metadata.metadata) {
|
|
2172
|
-
frontmatter.metadata = metadata.metadata;
|
|
2173
|
-
}
|
|
2174
|
-
return matter.stringify(instructions, frontmatter);
|
|
2175
|
-
}
|
|
2176
2053
|
/**
|
|
2177
2054
|
* Join path segments (workspace paths use forward slashes)
|
|
2178
2055
|
*/
|
|
@@ -2201,30 +2078,6 @@ ${validation.errors.join("\n")}`);
|
|
|
2201
2078
|
const lastSlash = path4.lastIndexOf("/");
|
|
2202
2079
|
return lastSlash > 0 ? path4.substring(0, lastSlash) : "/";
|
|
2203
2080
|
}
|
|
2204
|
-
/**
|
|
2205
|
-
* Ensure parent directory exists for a file path.
|
|
2206
|
-
* Recursively creates parent directories if they don't exist.
|
|
2207
|
-
* Only called from write operations that already checked #isWritable.
|
|
2208
|
-
*/
|
|
2209
|
-
async #ensureParentDir(filePath) {
|
|
2210
|
-
const parentPath = this.#getParentPath(filePath);
|
|
2211
|
-
if (parentPath && parentPath !== "/") {
|
|
2212
|
-
await this.#mkdirRecursive(parentPath);
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
/**
|
|
2216
|
-
* Recursively create directories if they don't exist.
|
|
2217
|
-
*/
|
|
2218
|
-
async #mkdirRecursive(dirPath) {
|
|
2219
|
-
if (await this.#source.exists(dirPath)) {
|
|
2220
|
-
return;
|
|
2221
|
-
}
|
|
2222
|
-
const parentPath = this.#getParentPath(dirPath);
|
|
2223
|
-
if (parentPath && parentPath !== "/") {
|
|
2224
|
-
await this.#mkdirRecursive(parentPath);
|
|
2225
|
-
}
|
|
2226
|
-
await this.#getWritableSource().mkdir(dirPath);
|
|
2227
|
-
}
|
|
2228
2081
|
};
|
|
2229
2082
|
|
|
2230
2083
|
// src/workspace/workspace.ts
|
|
@@ -2281,12 +2134,6 @@ var Workspace = class {
|
|
|
2281
2134
|
get filesystem() {
|
|
2282
2135
|
return this._fs;
|
|
2283
2136
|
}
|
|
2284
|
-
/**
|
|
2285
|
-
* Alias for filesystem.
|
|
2286
|
-
*/
|
|
2287
|
-
get fs() {
|
|
2288
|
-
return this._fs;
|
|
2289
|
-
}
|
|
2290
2137
|
/**
|
|
2291
2138
|
* The sandbox provider (if configured).
|
|
2292
2139
|
*/
|
|
@@ -2306,19 +2153,11 @@ var Workspace = class {
|
|
|
2306
2153
|
*
|
|
2307
2154
|
* Returns undefined if no skillPaths are configured.
|
|
2308
2155
|
*
|
|
2309
|
-
* When filesystem is available, skills support full CRUD operations.
|
|
2310
|
-
* Without filesystem, skills are loaded read-only via LocalSkillSource.
|
|
2311
|
-
*
|
|
2312
2156
|
* @example
|
|
2313
2157
|
* ```typescript
|
|
2314
2158
|
* const skills = await workspace.skills?.list();
|
|
2315
2159
|
* const skill = await workspace.skills?.get('brand-guidelines');
|
|
2316
2160
|
* const results = await workspace.skills?.search('brand colors');
|
|
2317
|
-
*
|
|
2318
|
-
* // CRUD operations (only available with filesystem)
|
|
2319
|
-
* if (workspace.skills?.isWritable) {
|
|
2320
|
-
* await workspace.skills.create({ ... });
|
|
2321
|
-
* }
|
|
2322
2161
|
* ```
|
|
2323
2162
|
*/
|
|
2324
2163
|
get skills() {
|
|
@@ -3226,22 +3065,22 @@ function createWorkspaceTools(workspace) {
|
|
|
3226
3065
|
id: WORKSPACE_TOOLS.FILESYSTEM.READ_FILE,
|
|
3227
3066
|
description: "Read the contents of a file from the workspace filesystem. Supports reading specific line ranges using offset/limit parameters.",
|
|
3228
3067
|
requireApproval: readFileConfig.requireApproval,
|
|
3229
|
-
inputSchema: z
|
|
3230
|
-
path: z
|
|
3231
|
-
encoding: z
|
|
3232
|
-
offset: z
|
|
3233
|
-
limit: z
|
|
3234
|
-
showLineNumbers: z
|
|
3068
|
+
inputSchema: z.object({
|
|
3069
|
+
path: z.string().describe('The path to the file to read (e.g., "/data/config.json")'),
|
|
3070
|
+
encoding: z.enum(["utf-8", "utf8", "base64", "hex", "binary"]).optional().describe("The encoding to use when reading the file. Defaults to utf-8 for text files."),
|
|
3071
|
+
offset: z.number().optional().describe("Line number to start reading from (1-indexed). If omitted, starts from line 1."),
|
|
3072
|
+
limit: z.number().optional().describe("Maximum number of lines to read. If omitted, reads to the end of the file."),
|
|
3073
|
+
showLineNumbers: z.boolean().optional().default(true).describe("Whether to prefix each line with its line number (default: true)")
|
|
3235
3074
|
}),
|
|
3236
|
-
outputSchema: z
|
|
3237
|
-
content: z
|
|
3238
|
-
size: z
|
|
3239
|
-
path: z
|
|
3240
|
-
lines: z
|
|
3241
|
-
start: z
|
|
3242
|
-
end: z
|
|
3075
|
+
outputSchema: z.object({
|
|
3076
|
+
content: z.string().describe("The file contents (with optional line number prefixes)"),
|
|
3077
|
+
size: z.number().describe("The file size in bytes"),
|
|
3078
|
+
path: z.string().describe("The full path to the file"),
|
|
3079
|
+
lines: z.object({
|
|
3080
|
+
start: z.number().describe("First line number returned"),
|
|
3081
|
+
end: z.number().describe("Last line number returned")
|
|
3243
3082
|
}).optional().describe("Line range information (when offset/limit used)"),
|
|
3244
|
-
totalLines: z
|
|
3083
|
+
totalLines: z.number().optional().describe("Total number of lines in the file")
|
|
3245
3084
|
}),
|
|
3246
3085
|
execute: async ({ path: path4, encoding, offset, limit, showLineNumbers }) => {
|
|
3247
3086
|
const effectiveEncoding = encoding ?? "utf-8";
|
|
@@ -3288,15 +3127,15 @@ function createWorkspaceTools(workspace) {
|
|
|
3288
3127
|
id: WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE,
|
|
3289
3128
|
description: "Write content to a file in the workspace filesystem. Creates parent directories if needed.",
|
|
3290
3129
|
requireApproval: writeFileConfig.requireApproval,
|
|
3291
|
-
inputSchema: z
|
|
3292
|
-
path: z
|
|
3293
|
-
content: z
|
|
3294
|
-
overwrite: z
|
|
3130
|
+
inputSchema: z.object({
|
|
3131
|
+
path: z.string().describe('The path where to write the file (e.g., "/data/output.txt")'),
|
|
3132
|
+
content: z.string().describe("The content to write to the file"),
|
|
3133
|
+
overwrite: z.boolean().optional().default(true).describe("Whether to overwrite the file if it already exists")
|
|
3295
3134
|
}),
|
|
3296
|
-
outputSchema: z
|
|
3297
|
-
success: z
|
|
3298
|
-
path: z
|
|
3299
|
-
size: z
|
|
3135
|
+
outputSchema: z.object({
|
|
3136
|
+
success: z.boolean(),
|
|
3137
|
+
path: z.string().describe("The path where the file was written"),
|
|
3138
|
+
size: z.number().describe("The size of the written content in bytes")
|
|
3300
3139
|
}),
|
|
3301
3140
|
execute: async ({ path: path4, content, overwrite }) => {
|
|
3302
3141
|
if (readTracker && writeFileConfig.requireReadBeforeWrite) {
|
|
@@ -3329,17 +3168,17 @@ function createWorkspaceTools(workspace) {
|
|
|
3329
3168
|
id: WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE,
|
|
3330
3169
|
description: "Edit a file by replacing specific text. The old_string must match exactly and be unique in the file (unless using replace_all). You should read the file first to ensure you have the exact text to replace.",
|
|
3331
3170
|
requireApproval: editFileConfig.requireApproval,
|
|
3332
|
-
inputSchema: z
|
|
3333
|
-
path: z
|
|
3334
|
-
old_string: z
|
|
3335
|
-
new_string: z
|
|
3336
|
-
replace_all: z
|
|
3171
|
+
inputSchema: z.object({
|
|
3172
|
+
path: z.string().describe("The path to the file to edit"),
|
|
3173
|
+
old_string: z.string().describe("The exact text to find and replace. Must be unique in the file."),
|
|
3174
|
+
new_string: z.string().describe("The text to replace old_string with"),
|
|
3175
|
+
replace_all: z.boolean().optional().default(false).describe("If true, replace all occurrences. If false (default), old_string must be unique.")
|
|
3337
3176
|
}),
|
|
3338
|
-
outputSchema: z
|
|
3339
|
-
success: z
|
|
3340
|
-
path: z
|
|
3341
|
-
replacements: z
|
|
3342
|
-
error: z
|
|
3177
|
+
outputSchema: z.object({
|
|
3178
|
+
success: z.boolean(),
|
|
3179
|
+
path: z.string().describe("The path to the edited file"),
|
|
3180
|
+
replacements: z.number().describe("Number of replacements made"),
|
|
3181
|
+
error: z.string().optional().describe("Error message if the edit failed")
|
|
3343
3182
|
}),
|
|
3344
3183
|
execute: async ({ path: path4, old_string, new_string, replace_all }) => {
|
|
3345
3184
|
try {
|
|
@@ -3409,26 +3248,26 @@ Examples:
|
|
|
3409
3248
|
- Directories only: { path: "/", dirsOnly: true }
|
|
3410
3249
|
- Exclude node_modules: { path: "/", exclude: "node_modules" }`,
|
|
3411
3250
|
requireApproval: listFilesConfig.requireApproval,
|
|
3412
|
-
inputSchema: z
|
|
3413
|
-
path: z
|
|
3414
|
-
maxDepth: z
|
|
3415
|
-
showHidden: z
|
|
3416
|
-
dirsOnly: z
|
|
3417
|
-
exclude: z
|
|
3418
|
-
extension: z
|
|
3251
|
+
inputSchema: z.object({
|
|
3252
|
+
path: z.string().default("/").describe("Directory path to list"),
|
|
3253
|
+
maxDepth: z.number().optional().default(3).describe("Maximum depth to descend (default: 3). Similar to tree -L flag."),
|
|
3254
|
+
showHidden: z.boolean().optional().default(false).describe('Show hidden files starting with "." (default: false). Similar to tree -a flag.'),
|
|
3255
|
+
dirsOnly: z.boolean().optional().default(false).describe("List directories only, no files (default: false). Similar to tree -d flag."),
|
|
3256
|
+
exclude: z.string().optional().describe('Pattern to exclude (e.g., "node_modules"). Similar to tree -I flag.'),
|
|
3257
|
+
extension: z.string().optional().describe('Filter by file extension (e.g., ".ts"). Similar to tree -P flag.')
|
|
3419
3258
|
}),
|
|
3420
|
-
outputSchema: z
|
|
3421
|
-
tree: z
|
|
3422
|
-
summary: z
|
|
3423
|
-
metadata: z
|
|
3424
|
-
workspace: z
|
|
3425
|
-
id: z
|
|
3426
|
-
name: z
|
|
3259
|
+
outputSchema: z.object({
|
|
3260
|
+
tree: z.string().describe("Tree-style directory listing"),
|
|
3261
|
+
summary: z.string().describe('Summary of directories and files (e.g., "3 directories, 12 files")'),
|
|
3262
|
+
metadata: z.object({
|
|
3263
|
+
workspace: z.object({
|
|
3264
|
+
id: z.string().optional(),
|
|
3265
|
+
name: z.string().optional()
|
|
3427
3266
|
}).optional(),
|
|
3428
|
-
filesystem: z
|
|
3429
|
-
id: z
|
|
3430
|
-
name: z
|
|
3431
|
-
provider: z
|
|
3267
|
+
filesystem: z.object({
|
|
3268
|
+
id: z.string().optional(),
|
|
3269
|
+
name: z.string().optional(),
|
|
3270
|
+
provider: z.string().optional()
|
|
3432
3271
|
}).optional()
|
|
3433
3272
|
}).optional().describe("Metadata about the workspace and filesystem")
|
|
3434
3273
|
}),
|
|
@@ -3466,15 +3305,15 @@ Examples:
|
|
|
3466
3305
|
id: WORKSPACE_TOOLS.FILESYSTEM.DELETE,
|
|
3467
3306
|
description: "Delete a file or directory from the workspace filesystem",
|
|
3468
3307
|
requireApproval: deleteConfig.requireApproval,
|
|
3469
|
-
inputSchema: z
|
|
3470
|
-
path: z
|
|
3471
|
-
recursive: z
|
|
3308
|
+
inputSchema: z.object({
|
|
3309
|
+
path: z.string().describe("The path to the file or directory to delete"),
|
|
3310
|
+
recursive: z.boolean().optional().default(false).describe(
|
|
3472
3311
|
"If true, delete directories and their contents recursively. Required for non-empty directories."
|
|
3473
3312
|
)
|
|
3474
3313
|
}),
|
|
3475
|
-
outputSchema: z
|
|
3476
|
-
success: z
|
|
3477
|
-
path: z
|
|
3314
|
+
outputSchema: z.object({
|
|
3315
|
+
success: z.boolean(),
|
|
3316
|
+
path: z.string()
|
|
3478
3317
|
}),
|
|
3479
3318
|
execute: async ({ path: path4, recursive }) => {
|
|
3480
3319
|
const stat3 = await workspace.filesystem.stat(path4);
|
|
@@ -3493,14 +3332,14 @@ Examples:
|
|
|
3493
3332
|
id: WORKSPACE_TOOLS.FILESYSTEM.FILE_STAT,
|
|
3494
3333
|
description: "Get file or directory metadata from the workspace. Returns existence, type, size, and modification time.",
|
|
3495
3334
|
requireApproval: fileStatConfig.requireApproval,
|
|
3496
|
-
inputSchema: z
|
|
3497
|
-
path: z
|
|
3335
|
+
inputSchema: z.object({
|
|
3336
|
+
path: z.string().describe("The path to check")
|
|
3498
3337
|
}),
|
|
3499
|
-
outputSchema: z
|
|
3500
|
-
exists: z
|
|
3501
|
-
type: z
|
|
3502
|
-
size: z
|
|
3503
|
-
modifiedAt: z
|
|
3338
|
+
outputSchema: z.object({
|
|
3339
|
+
exists: z.boolean().describe("Whether the path exists"),
|
|
3340
|
+
type: z.enum(["file", "directory", "none"]).describe("The type of the path if it exists"),
|
|
3341
|
+
size: z.number().optional().describe("Size in bytes (for files)"),
|
|
3342
|
+
modifiedAt: z.string().optional().describe("Last modification time (ISO string)")
|
|
3504
3343
|
}),
|
|
3505
3344
|
execute: async ({ path: path4 }) => {
|
|
3506
3345
|
try {
|
|
@@ -3526,13 +3365,13 @@ Examples:
|
|
|
3526
3365
|
id: WORKSPACE_TOOLS.FILESYSTEM.MKDIR,
|
|
3527
3366
|
description: "Create a directory in the workspace filesystem",
|
|
3528
3367
|
requireApproval: mkdirConfig.requireApproval,
|
|
3529
|
-
inputSchema: z
|
|
3530
|
-
path: z
|
|
3531
|
-
recursive: z
|
|
3368
|
+
inputSchema: z.object({
|
|
3369
|
+
path: z.string().describe("The path of the directory to create"),
|
|
3370
|
+
recursive: z.boolean().optional().default(true).describe("Whether to create parent directories if they do not exist")
|
|
3532
3371
|
}),
|
|
3533
|
-
outputSchema: z
|
|
3534
|
-
success: z
|
|
3535
|
-
path: z
|
|
3372
|
+
outputSchema: z.object({
|
|
3373
|
+
success: z.boolean(),
|
|
3374
|
+
path: z.string()
|
|
3536
3375
|
}),
|
|
3537
3376
|
execute: async ({ path: path4, recursive }) => {
|
|
3538
3377
|
await workspace.filesystem.mkdir(path4, { recursive });
|
|
@@ -3548,26 +3387,26 @@ Examples:
|
|
|
3548
3387
|
id: WORKSPACE_TOOLS.SEARCH.SEARCH,
|
|
3549
3388
|
description: "Search indexed content in the workspace. Supports keyword (BM25), semantic (vector), and hybrid search modes.",
|
|
3550
3389
|
requireApproval: searchConfig.requireApproval,
|
|
3551
|
-
inputSchema: z
|
|
3552
|
-
query: z
|
|
3553
|
-
topK: z
|
|
3554
|
-
mode: z
|
|
3555
|
-
minScore: z
|
|
3390
|
+
inputSchema: z.object({
|
|
3391
|
+
query: z.string().describe("The search query string"),
|
|
3392
|
+
topK: z.number().optional().default(5).describe("Maximum number of results to return"),
|
|
3393
|
+
mode: z.enum(["bm25", "vector", "hybrid"]).optional().describe("Search mode: bm25 for keyword search, vector for semantic search, hybrid for both combined"),
|
|
3394
|
+
minScore: z.number().optional().describe("Minimum score threshold (0-1 for normalized scores)")
|
|
3556
3395
|
}),
|
|
3557
|
-
outputSchema: z
|
|
3558
|
-
results: z
|
|
3559
|
-
z
|
|
3560
|
-
id: z
|
|
3561
|
-
content: z
|
|
3562
|
-
score: z
|
|
3563
|
-
lineRange: z
|
|
3564
|
-
start: z
|
|
3565
|
-
end: z
|
|
3396
|
+
outputSchema: z.object({
|
|
3397
|
+
results: z.array(
|
|
3398
|
+
z.object({
|
|
3399
|
+
id: z.string().describe("Document/file path"),
|
|
3400
|
+
content: z.string().describe("The matching content"),
|
|
3401
|
+
score: z.number().describe("Relevance score"),
|
|
3402
|
+
lineRange: z.object({
|
|
3403
|
+
start: z.number(),
|
|
3404
|
+
end: z.number()
|
|
3566
3405
|
}).optional().describe("Line range where query terms were found")
|
|
3567
3406
|
})
|
|
3568
3407
|
),
|
|
3569
|
-
count: z
|
|
3570
|
-
mode: z
|
|
3408
|
+
count: z.number().describe("Number of results returned"),
|
|
3409
|
+
mode: z.string().describe("The search mode that was used")
|
|
3571
3410
|
}),
|
|
3572
3411
|
execute: async ({ query, topK, mode, minScore }) => {
|
|
3573
3412
|
const results = await workspace.search(query, {
|
|
@@ -3594,14 +3433,14 @@ Examples:
|
|
|
3594
3433
|
id: WORKSPACE_TOOLS.SEARCH.INDEX,
|
|
3595
3434
|
description: "Index content for search. The path becomes the document ID in search results.",
|
|
3596
3435
|
requireApproval: indexConfig.requireApproval,
|
|
3597
|
-
inputSchema: z
|
|
3598
|
-
path: z
|
|
3599
|
-
content: z
|
|
3600
|
-
metadata: z
|
|
3436
|
+
inputSchema: z.object({
|
|
3437
|
+
path: z.string().describe("The document ID/path for search results"),
|
|
3438
|
+
content: z.string().describe("The text content to index"),
|
|
3439
|
+
metadata: z.record(z.unknown()).optional().describe("Optional metadata to store with the document")
|
|
3601
3440
|
}),
|
|
3602
|
-
outputSchema: z
|
|
3603
|
-
success: z
|
|
3604
|
-
path: z
|
|
3441
|
+
outputSchema: z.object({
|
|
3442
|
+
success: z.boolean(),
|
|
3443
|
+
path: z.string().describe("The indexed document ID")
|
|
3605
3444
|
}),
|
|
3606
3445
|
execute: async ({ path: path4, content, metadata }) => {
|
|
3607
3446
|
await workspace.index(path4, content, { metadata });
|
|
@@ -3619,20 +3458,20 @@ Examples:
|
|
|
3619
3458
|
id: WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND,
|
|
3620
3459
|
description: `Execute a shell command in the workspace sandbox. The output (stdout/stderr) is displayed to the user automatically in the tool result. ${pathInfo}`,
|
|
3621
3460
|
requireApproval: executeCommandConfig.requireApproval,
|
|
3622
|
-
inputSchema: z
|
|
3623
|
-
command: z
|
|
3624
|
-
args: z
|
|
3625
|
-
timeout: z
|
|
3461
|
+
inputSchema: z.object({
|
|
3462
|
+
command: z.string().describe('The command to execute (e.g., "ls", "npm", "python")'),
|
|
3463
|
+
args: z.array(z.string()).nullish().default([]).describe("Arguments to pass to the command"),
|
|
3464
|
+
timeout: z.number().nullish().default(3e4).describe(
|
|
3626
3465
|
"Maximum execution time in milliseconds. Default is 30000 (30 seconds). Example: 60000 for 1 minute."
|
|
3627
3466
|
),
|
|
3628
|
-
cwd: z
|
|
3467
|
+
cwd: z.string().nullish().describe("Working directory for the command")
|
|
3629
3468
|
}),
|
|
3630
|
-
outputSchema: z
|
|
3631
|
-
success: z
|
|
3632
|
-
stdout: z
|
|
3633
|
-
stderr: z
|
|
3634
|
-
exitCode: z
|
|
3635
|
-
executionTimeMs: z
|
|
3469
|
+
outputSchema: z.object({
|
|
3470
|
+
success: z.boolean().describe("Whether the command executed successfully (exit code 0)"),
|
|
3471
|
+
stdout: z.string().describe("Standard output from the command"),
|
|
3472
|
+
stderr: z.string().describe("Standard error output"),
|
|
3473
|
+
exitCode: z.number().describe("Exit code (0 = success)"),
|
|
3474
|
+
executionTimeMs: z.number().describe("How long the execution took in milliseconds")
|
|
3636
3475
|
}),
|
|
3637
3476
|
execute: async ({ command, args, timeout, cwd }, context) => {
|
|
3638
3477
|
const getExecutionMetadata = () => ({
|
|
@@ -3702,5 +3541,5 @@ Examples:
|
|
|
3702
3541
|
}
|
|
3703
3542
|
|
|
3704
3543
|
export { DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, FileReadRequiredError, FilesystemError, FilesystemNotAvailableError, IsDirectoryError, IsolationUnavailableError, LocalFilesystem, LocalSandbox, NotDirectoryError, PermissionError, SandboxError, SandboxExecutionError, SandboxFeatureNotSupportedError, SandboxNotAvailableError, SandboxNotReadyError, SandboxTimeoutError, SearchNotAvailableError, WORKSPACE_TOOLS, WORKSPACE_TOOLS_PREFIX, Workspace, WorkspaceError, WorkspaceNotReadyError, WorkspaceReadOnlyError, createWorkspaceTools, detectIsolation, extractLines, getRecommendedIsolation, isIsolationAvailable, resolveToolConfig };
|
|
3705
|
-
//# sourceMappingURL=chunk-
|
|
3706
|
-
//# sourceMappingURL=chunk-
|
|
3544
|
+
//# sourceMappingURL=chunk-4KQEQ4NM.js.map
|
|
3545
|
+
//# sourceMappingURL=chunk-4KQEQ4NM.js.map
|