@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,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkIIZF4W7B_cjs = require('./chunk-IIZF4W7B.cjs');
|
|
4
|
-
var z = require('zod');
|
|
5
4
|
var fs2 = require('fs/promises');
|
|
6
5
|
var nodePath = require('path');
|
|
7
6
|
var fs = require('fs');
|
|
@@ -9,6 +8,7 @@ var matter = require('gray-matter');
|
|
|
9
8
|
var childProcess = require('child_process');
|
|
10
9
|
var crypto = require('crypto');
|
|
11
10
|
var os = require('os');
|
|
11
|
+
var zod = require('zod');
|
|
12
12
|
|
|
13
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
|
|
@@ -30,7 +30,6 @@ function _interopNamespace(e) {
|
|
|
30
30
|
return Object.freeze(n);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
var z__default = /*#__PURE__*/_interopDefault(z);
|
|
34
33
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
35
34
|
var nodePath__namespace = /*#__PURE__*/_interopNamespace(nodePath);
|
|
36
35
|
var matter__default = /*#__PURE__*/_interopDefault(matter);
|
|
@@ -858,6 +857,8 @@ var SearchEngine = class {
|
|
|
858
857
|
};
|
|
859
858
|
}
|
|
860
859
|
};
|
|
860
|
+
|
|
861
|
+
// src/workspace/skills/schemas.ts
|
|
861
862
|
var SKILL_LIMITS = {
|
|
862
863
|
/** Recommended max tokens for instructions */
|
|
863
864
|
MAX_INSTRUCTION_TOKENS: 5e3,
|
|
@@ -866,34 +867,77 @@ var SKILL_LIMITS = {
|
|
|
866
867
|
/** Max characters for name field */
|
|
867
868
|
MAX_NAME_LENGTH: 64,
|
|
868
869
|
/** Max characters for description field */
|
|
869
|
-
MAX_DESCRIPTION_LENGTH: 1024
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
870
|
+
MAX_DESCRIPTION_LENGTH: 1024};
|
|
871
|
+
function validateSkillName(name) {
|
|
872
|
+
const errors = [];
|
|
873
|
+
const fieldPath = "name";
|
|
874
|
+
if (typeof name !== "string") {
|
|
875
|
+
errors.push(`${fieldPath}: Expected string, received ${typeof name}`);
|
|
876
|
+
return errors;
|
|
877
|
+
}
|
|
878
|
+
if (name.length === 0) {
|
|
879
|
+
errors.push(`${fieldPath}: Skill name cannot be empty`);
|
|
880
|
+
return errors;
|
|
881
|
+
}
|
|
882
|
+
if (name.length > SKILL_LIMITS.MAX_NAME_LENGTH) {
|
|
883
|
+
errors.push(`${fieldPath}: Skill name must be ${SKILL_LIMITS.MAX_NAME_LENGTH} characters or less`);
|
|
884
|
+
}
|
|
885
|
+
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
886
|
+
errors.push(`${fieldPath}: Skill name must contain only lowercase letters, numbers, and hyphens`);
|
|
887
|
+
}
|
|
888
|
+
if (name.startsWith("-") || name.endsWith("-")) {
|
|
889
|
+
errors.push(`${fieldPath}: Skill name must not start or end with a hyphen`);
|
|
890
|
+
}
|
|
891
|
+
if (name.includes("--")) {
|
|
892
|
+
errors.push(`${fieldPath}: Skill name must not contain consecutive hyphens`);
|
|
893
|
+
}
|
|
894
|
+
return errors;
|
|
895
|
+
}
|
|
896
|
+
function validateSkillDescription(description) {
|
|
897
|
+
const errors = [];
|
|
898
|
+
const fieldPath = "description";
|
|
899
|
+
if (typeof description !== "string") {
|
|
900
|
+
errors.push(`${fieldPath}: Expected string, received ${typeof description}`);
|
|
901
|
+
return errors;
|
|
902
|
+
}
|
|
903
|
+
if (description.length === 0) {
|
|
904
|
+
errors.push(`${fieldPath}: Skill description cannot be empty`);
|
|
905
|
+
return errors;
|
|
906
|
+
}
|
|
907
|
+
if (description.length > SKILL_LIMITS.MAX_DESCRIPTION_LENGTH) {
|
|
908
|
+
errors.push(`${fieldPath}: Skill description must be ${SKILL_LIMITS.MAX_DESCRIPTION_LENGTH} characters or less`);
|
|
909
|
+
}
|
|
910
|
+
if (description.trim().length === 0) {
|
|
911
|
+
errors.push(`${fieldPath}: Skill description cannot be only whitespace`);
|
|
912
|
+
}
|
|
913
|
+
return errors;
|
|
914
|
+
}
|
|
915
|
+
function validateSkillLicense(license) {
|
|
916
|
+
const errors = [];
|
|
917
|
+
const fieldPath = "license";
|
|
918
|
+
if (license === void 0 || license === null) {
|
|
919
|
+
return errors;
|
|
920
|
+
}
|
|
921
|
+
if (typeof license !== "string") {
|
|
922
|
+
errors.push(`${fieldPath}: Expected string, received ${typeof license}`);
|
|
923
|
+
}
|
|
924
|
+
return errors;
|
|
925
|
+
}
|
|
926
|
+
function validateSkillCompatibility(_compatibility) {
|
|
927
|
+
return [];
|
|
928
|
+
}
|
|
929
|
+
function validateSkillMetadataField(metadata) {
|
|
930
|
+
const errors = [];
|
|
931
|
+
const fieldPath = "metadata";
|
|
932
|
+
if (metadata === void 0 || metadata === null) {
|
|
933
|
+
return errors;
|
|
934
|
+
}
|
|
935
|
+
if (typeof metadata !== "object" || Array.isArray(metadata)) {
|
|
936
|
+
errors.push(`${fieldPath}: Expected object, received ${Array.isArray(metadata) ? "array" : typeof metadata}`);
|
|
937
|
+
return errors;
|
|
938
|
+
}
|
|
939
|
+
return errors;
|
|
940
|
+
}
|
|
897
941
|
function estimateTokens(text) {
|
|
898
942
|
const words = text.split(/\s+/).filter(Boolean).length;
|
|
899
943
|
return Math.ceil(words * 1.3);
|
|
@@ -904,12 +948,20 @@ function countLines(text) {
|
|
|
904
948
|
function validateSkillMetadata(metadata, dirName, instructions) {
|
|
905
949
|
const errors = [];
|
|
906
950
|
const warnings = [];
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
951
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata)) {
|
|
952
|
+
errors.push(
|
|
953
|
+
`Expected object, received ${metadata === null ? "null" : Array.isArray(metadata) ? "array" : typeof metadata}`
|
|
954
|
+
);
|
|
955
|
+
return { valid: false, errors, warnings };
|
|
910
956
|
}
|
|
911
|
-
|
|
912
|
-
|
|
957
|
+
const data = metadata;
|
|
958
|
+
errors.push(...validateSkillName(data.name));
|
|
959
|
+
errors.push(...validateSkillDescription(data.description));
|
|
960
|
+
errors.push(...validateSkillLicense(data.license));
|
|
961
|
+
errors.push(...validateSkillCompatibility());
|
|
962
|
+
errors.push(...validateSkillMetadataField(data.metadata));
|
|
963
|
+
if (dirName && typeof data.name === "string" && data.name !== dirName) {
|
|
964
|
+
errors.push(`Skill name "${data.name}" must match directory name "${dirName}"`);
|
|
913
965
|
}
|
|
914
966
|
if (instructions) {
|
|
915
967
|
const lineCount = countLines(instructions);
|
|
@@ -931,11 +983,6 @@ function validateSkillMetadata(metadata, dirName, instructions) {
|
|
|
931
983
|
warnings
|
|
932
984
|
};
|
|
933
985
|
}
|
|
934
|
-
|
|
935
|
-
// src/workspace/skills/skill-source.ts
|
|
936
|
-
function isWritableSource(source) {
|
|
937
|
-
return "writeFile" in source && typeof source.writeFile === "function" && "mkdir" in source && typeof source.mkdir === "function" && "rmdir" in source && typeof source.rmdir === "function";
|
|
938
|
-
}
|
|
939
986
|
function isEnoentError(error) {
|
|
940
987
|
return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
|
|
941
988
|
}
|
|
@@ -1557,7 +1604,6 @@ var WorkspaceSkillsImpl = class {
|
|
|
1557
1604
|
#skillsResolver;
|
|
1558
1605
|
#searchEngine;
|
|
1559
1606
|
#validateOnLoad;
|
|
1560
|
-
#isWritable;
|
|
1561
1607
|
/** Map of skill name -> full skill data */
|
|
1562
1608
|
#skills = /* @__PURE__ */ new Map();
|
|
1563
1609
|
/** Whether skills have been discovered */
|
|
@@ -1573,21 +1619,6 @@ var WorkspaceSkillsImpl = class {
|
|
|
1573
1619
|
this.#skillsResolver = config.skills;
|
|
1574
1620
|
this.#searchEngine = config.searchEngine;
|
|
1575
1621
|
this.#validateOnLoad = config.validateOnLoad ?? true;
|
|
1576
|
-
this.#isWritable = isWritableSource(this.#source);
|
|
1577
|
-
}
|
|
1578
|
-
/**
|
|
1579
|
-
* Whether this skills instance supports write operations.
|
|
1580
|
-
* Returns true if backed by a WorkspaceFilesystem, false for read-only sources.
|
|
1581
|
-
*/
|
|
1582
|
-
get isWritable() {
|
|
1583
|
-
return this.#isWritable;
|
|
1584
|
-
}
|
|
1585
|
-
/**
|
|
1586
|
-
* Get the source as a writable source.
|
|
1587
|
-
* Only call after checking #isWritable is true.
|
|
1588
|
-
*/
|
|
1589
|
-
#getWritableSource() {
|
|
1590
|
-
return this.#source;
|
|
1591
1622
|
}
|
|
1592
1623
|
// ===========================================================================
|
|
1593
1624
|
// Discovery
|
|
@@ -1692,142 +1723,6 @@ var WorkspaceSkillsImpl = class {
|
|
|
1692
1723
|
return results;
|
|
1693
1724
|
}
|
|
1694
1725
|
// ===========================================================================
|
|
1695
|
-
// CRUD Operations
|
|
1696
|
-
// ===========================================================================
|
|
1697
|
-
async create(input) {
|
|
1698
|
-
await this.#ensureInitialized();
|
|
1699
|
-
if (!this.#isWritable) {
|
|
1700
|
-
throw new Error("Skills are read-only. Write operations require a WorkspaceFilesystem.");
|
|
1701
|
-
}
|
|
1702
|
-
const { metadata, instructions, references, scripts, assets } = input;
|
|
1703
|
-
if (this.#skills.has(metadata.name)) {
|
|
1704
|
-
throw new Error(`Skill "${metadata.name}" already exists`);
|
|
1705
|
-
}
|
|
1706
|
-
if (this.#validateOnLoad) {
|
|
1707
|
-
const validation = this.#validateSkillMetadata(metadata, metadata.name, instructions);
|
|
1708
|
-
if (!validation.valid) {
|
|
1709
|
-
throw new Error(`Invalid skill metadata:
|
|
1710
|
-
${validation.errors.join("\n")}`);
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
const skillsPath = this.#resolvedPaths[0];
|
|
1714
|
-
if (!skillsPath) {
|
|
1715
|
-
throw new Error("No skills path configured for creating skills");
|
|
1716
|
-
}
|
|
1717
|
-
const skillDir = this.#joinPath(skillsPath, metadata.name);
|
|
1718
|
-
if (await this.#source.exists(skillDir)) {
|
|
1719
|
-
throw new Error(`Directory "${skillDir}" already exists`);
|
|
1720
|
-
}
|
|
1721
|
-
const fs5 = this.#getWritableSource();
|
|
1722
|
-
await fs5.mkdir(skillDir);
|
|
1723
|
-
const skillMdContent = this.#buildSkillMd(metadata, instructions);
|
|
1724
|
-
await fs5.writeFile(this.#joinPath(skillDir, "SKILL.md"), skillMdContent);
|
|
1725
|
-
const refPaths = [];
|
|
1726
|
-
if (references && references.length > 0) {
|
|
1727
|
-
const refsDir = this.#joinPath(skillDir, "references");
|
|
1728
|
-
await fs5.mkdir(refsDir);
|
|
1729
|
-
for (const ref of references) {
|
|
1730
|
-
const safeRefPath = this.#assertRelativePath(ref.path, "reference");
|
|
1731
|
-
const refPath = this.#joinPath(refsDir, safeRefPath);
|
|
1732
|
-
await this.#ensureParentDir(refPath);
|
|
1733
|
-
await fs5.writeFile(refPath, ref.content);
|
|
1734
|
-
refPaths.push(safeRefPath);
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
const scriptPaths = [];
|
|
1738
|
-
if (scripts && scripts.length > 0) {
|
|
1739
|
-
const scriptsDir = this.#joinPath(skillDir, "scripts");
|
|
1740
|
-
await fs5.mkdir(scriptsDir);
|
|
1741
|
-
for (const script of scripts) {
|
|
1742
|
-
const safeScriptPath = this.#assertRelativePath(script.path, "script");
|
|
1743
|
-
const scriptPath = this.#joinPath(scriptsDir, safeScriptPath);
|
|
1744
|
-
await this.#ensureParentDir(scriptPath);
|
|
1745
|
-
await fs5.writeFile(scriptPath, script.content);
|
|
1746
|
-
scriptPaths.push(safeScriptPath);
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
const assetPaths = [];
|
|
1750
|
-
if (assets && assets.length > 0) {
|
|
1751
|
-
const assetsDir = this.#joinPath(skillDir, "assets");
|
|
1752
|
-
await fs5.mkdir(assetsDir);
|
|
1753
|
-
for (const asset of assets) {
|
|
1754
|
-
const safeAssetPath = this.#assertRelativePath(asset.path, "asset");
|
|
1755
|
-
const assetPath = this.#joinPath(assetsDir, safeAssetPath);
|
|
1756
|
-
await this.#ensureParentDir(assetPath);
|
|
1757
|
-
await fs5.writeFile(assetPath, asset.content);
|
|
1758
|
-
assetPaths.push(safeAssetPath);
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
const source = this.#determineSource(skillsPath);
|
|
1762
|
-
const indexableContent = await this.#buildIndexableContent(instructions, skillDir, refPaths);
|
|
1763
|
-
const skill = {
|
|
1764
|
-
...metadata,
|
|
1765
|
-
path: skillDir,
|
|
1766
|
-
instructions,
|
|
1767
|
-
source,
|
|
1768
|
-
references: refPaths,
|
|
1769
|
-
scripts: scriptPaths,
|
|
1770
|
-
assets: assetPaths,
|
|
1771
|
-
indexableContent
|
|
1772
|
-
};
|
|
1773
|
-
this.#skills.set(metadata.name, skill);
|
|
1774
|
-
await this.#indexSkill(skill);
|
|
1775
|
-
const { indexableContent: _, ...skillData } = skill;
|
|
1776
|
-
return skillData;
|
|
1777
|
-
}
|
|
1778
|
-
async update(name, input) {
|
|
1779
|
-
await this.#ensureInitialized();
|
|
1780
|
-
if (!this.#isWritable) {
|
|
1781
|
-
throw new Error("Skills are read-only. Write operations require a WorkspaceFilesystem.");
|
|
1782
|
-
}
|
|
1783
|
-
const skill = this.#skills.get(name);
|
|
1784
|
-
if (!skill) {
|
|
1785
|
-
throw new Error(`Skill "${name}" not found`);
|
|
1786
|
-
}
|
|
1787
|
-
const { metadata: updatedMetadata, instructions: updatedInstructions } = input;
|
|
1788
|
-
const newMetadata = {
|
|
1789
|
-
name: skill.name,
|
|
1790
|
-
// Name cannot be changed
|
|
1791
|
-
description: updatedMetadata?.description ?? skill.description,
|
|
1792
|
-
license: updatedMetadata?.license ?? skill.license,
|
|
1793
|
-
compatibility: updatedMetadata?.compatibility ?? skill.compatibility,
|
|
1794
|
-
metadata: updatedMetadata?.metadata ?? skill.metadata
|
|
1795
|
-
};
|
|
1796
|
-
const newInstructions = updatedInstructions ?? skill.instructions;
|
|
1797
|
-
if (this.#validateOnLoad) {
|
|
1798
|
-
const validation = this.#validateSkillMetadata(newMetadata, name, newInstructions);
|
|
1799
|
-
if (!validation.valid) {
|
|
1800
|
-
throw new Error(`Invalid skill metadata:
|
|
1801
|
-
${validation.errors.join("\n")}`);
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
const skillMdContent = this.#buildSkillMd(newMetadata, newInstructions);
|
|
1805
|
-
await this.#getWritableSource().writeFile(this.#joinPath(skill.path, "SKILL.md"), skillMdContent);
|
|
1806
|
-
const indexableContent = await this.#buildIndexableContent(newInstructions, skill.path, skill.references);
|
|
1807
|
-
const updatedSkill = {
|
|
1808
|
-
...skill,
|
|
1809
|
-
...newMetadata,
|
|
1810
|
-
instructions: newInstructions,
|
|
1811
|
-
indexableContent
|
|
1812
|
-
};
|
|
1813
|
-
this.#skills.set(name, updatedSkill);
|
|
1814
|
-
await this.#indexSkill(updatedSkill);
|
|
1815
|
-
const { indexableContent: _, ...skillData } = updatedSkill;
|
|
1816
|
-
return skillData;
|
|
1817
|
-
}
|
|
1818
|
-
async delete(name) {
|
|
1819
|
-
await this.#ensureInitialized();
|
|
1820
|
-
if (!this.#isWritable) {
|
|
1821
|
-
throw new Error("Skills are read-only. Write operations require a WorkspaceFilesystem.");
|
|
1822
|
-
}
|
|
1823
|
-
const skill = this.#skills.get(name);
|
|
1824
|
-
if (!skill) {
|
|
1825
|
-
throw new Error(`Skill "${name}" not found`);
|
|
1826
|
-
}
|
|
1827
|
-
await this.#getWritableSource().rmdir(skill.path, { recursive: true });
|
|
1828
|
-
this.#skills.delete(name);
|
|
1829
|
-
}
|
|
1830
|
-
// ===========================================================================
|
|
1831
1726
|
// Single-item Accessors
|
|
1832
1727
|
// ===========================================================================
|
|
1833
1728
|
async getReference(skillName, referencePath) {
|
|
@@ -2182,25 +2077,6 @@ ${validation.errors.join("\n")}`);
|
|
|
2182
2077
|
}
|
|
2183
2078
|
return { type: "local", projectPath: skillsPath };
|
|
2184
2079
|
}
|
|
2185
|
-
/**
|
|
2186
|
-
* Build SKILL.md content from metadata and instructions
|
|
2187
|
-
*/
|
|
2188
|
-
#buildSkillMd(metadata, instructions) {
|
|
2189
|
-
const frontmatter = {
|
|
2190
|
-
name: metadata.name,
|
|
2191
|
-
description: metadata.description
|
|
2192
|
-
};
|
|
2193
|
-
if (metadata.license) {
|
|
2194
|
-
frontmatter.license = metadata.license;
|
|
2195
|
-
}
|
|
2196
|
-
if (metadata.compatibility) {
|
|
2197
|
-
frontmatter.compatibility = metadata.compatibility;
|
|
2198
|
-
}
|
|
2199
|
-
if (metadata.metadata) {
|
|
2200
|
-
frontmatter.metadata = metadata.metadata;
|
|
2201
|
-
}
|
|
2202
|
-
return matter__default.default.stringify(instructions, frontmatter);
|
|
2203
|
-
}
|
|
2204
2080
|
/**
|
|
2205
2081
|
* Join path segments (workspace paths use forward slashes)
|
|
2206
2082
|
*/
|
|
@@ -2229,30 +2105,6 @@ ${validation.errors.join("\n")}`);
|
|
|
2229
2105
|
const lastSlash = path4.lastIndexOf("/");
|
|
2230
2106
|
return lastSlash > 0 ? path4.substring(0, lastSlash) : "/";
|
|
2231
2107
|
}
|
|
2232
|
-
/**
|
|
2233
|
-
* Ensure parent directory exists for a file path.
|
|
2234
|
-
* Recursively creates parent directories if they don't exist.
|
|
2235
|
-
* Only called from write operations that already checked #isWritable.
|
|
2236
|
-
*/
|
|
2237
|
-
async #ensureParentDir(filePath) {
|
|
2238
|
-
const parentPath = this.#getParentPath(filePath);
|
|
2239
|
-
if (parentPath && parentPath !== "/") {
|
|
2240
|
-
await this.#mkdirRecursive(parentPath);
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
/**
|
|
2244
|
-
* Recursively create directories if they don't exist.
|
|
2245
|
-
*/
|
|
2246
|
-
async #mkdirRecursive(dirPath) {
|
|
2247
|
-
if (await this.#source.exists(dirPath)) {
|
|
2248
|
-
return;
|
|
2249
|
-
}
|
|
2250
|
-
const parentPath = this.#getParentPath(dirPath);
|
|
2251
|
-
if (parentPath && parentPath !== "/") {
|
|
2252
|
-
await this.#mkdirRecursive(parentPath);
|
|
2253
|
-
}
|
|
2254
|
-
await this.#getWritableSource().mkdir(dirPath);
|
|
2255
|
-
}
|
|
2256
2108
|
};
|
|
2257
2109
|
|
|
2258
2110
|
// src/workspace/workspace.ts
|
|
@@ -2309,12 +2161,6 @@ var Workspace = class {
|
|
|
2309
2161
|
get filesystem() {
|
|
2310
2162
|
return this._fs;
|
|
2311
2163
|
}
|
|
2312
|
-
/**
|
|
2313
|
-
* Alias for filesystem.
|
|
2314
|
-
*/
|
|
2315
|
-
get fs() {
|
|
2316
|
-
return this._fs;
|
|
2317
|
-
}
|
|
2318
2164
|
/**
|
|
2319
2165
|
* The sandbox provider (if configured).
|
|
2320
2166
|
*/
|
|
@@ -2334,19 +2180,11 @@ var Workspace = class {
|
|
|
2334
2180
|
*
|
|
2335
2181
|
* Returns undefined if no skillPaths are configured.
|
|
2336
2182
|
*
|
|
2337
|
-
* When filesystem is available, skills support full CRUD operations.
|
|
2338
|
-
* Without filesystem, skills are loaded read-only via LocalSkillSource.
|
|
2339
|
-
*
|
|
2340
2183
|
* @example
|
|
2341
2184
|
* ```typescript
|
|
2342
2185
|
* const skills = await workspace.skills?.list();
|
|
2343
2186
|
* const skill = await workspace.skills?.get('brand-guidelines');
|
|
2344
2187
|
* const results = await workspace.skills?.search('brand colors');
|
|
2345
|
-
*
|
|
2346
|
-
* // CRUD operations (only available with filesystem)
|
|
2347
|
-
* if (workspace.skills?.isWritable) {
|
|
2348
|
-
* await workspace.skills.create({ ... });
|
|
2349
|
-
* }
|
|
2350
2188
|
* ```
|
|
2351
2189
|
*/
|
|
2352
2190
|
get skills() {
|
|
@@ -3254,22 +3092,22 @@ function createWorkspaceTools(workspace) {
|
|
|
3254
3092
|
id: WORKSPACE_TOOLS.FILESYSTEM.READ_FILE,
|
|
3255
3093
|
description: "Read the contents of a file from the workspace filesystem. Supports reading specific line ranges using offset/limit parameters.",
|
|
3256
3094
|
requireApproval: readFileConfig.requireApproval,
|
|
3257
|
-
inputSchema:
|
|
3258
|
-
path:
|
|
3259
|
-
encoding:
|
|
3260
|
-
offset:
|
|
3261
|
-
limit:
|
|
3262
|
-
showLineNumbers:
|
|
3095
|
+
inputSchema: zod.z.object({
|
|
3096
|
+
path: zod.z.string().describe('The path to the file to read (e.g., "/data/config.json")'),
|
|
3097
|
+
encoding: zod.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."),
|
|
3098
|
+
offset: zod.z.number().optional().describe("Line number to start reading from (1-indexed). If omitted, starts from line 1."),
|
|
3099
|
+
limit: zod.z.number().optional().describe("Maximum number of lines to read. If omitted, reads to the end of the file."),
|
|
3100
|
+
showLineNumbers: zod.z.boolean().optional().default(true).describe("Whether to prefix each line with its line number (default: true)")
|
|
3263
3101
|
}),
|
|
3264
|
-
outputSchema:
|
|
3265
|
-
content:
|
|
3266
|
-
size:
|
|
3267
|
-
path:
|
|
3268
|
-
lines:
|
|
3269
|
-
start:
|
|
3270
|
-
end:
|
|
3102
|
+
outputSchema: zod.z.object({
|
|
3103
|
+
content: zod.z.string().describe("The file contents (with optional line number prefixes)"),
|
|
3104
|
+
size: zod.z.number().describe("The file size in bytes"),
|
|
3105
|
+
path: zod.z.string().describe("The full path to the file"),
|
|
3106
|
+
lines: zod.z.object({
|
|
3107
|
+
start: zod.z.number().describe("First line number returned"),
|
|
3108
|
+
end: zod.z.number().describe("Last line number returned")
|
|
3271
3109
|
}).optional().describe("Line range information (when offset/limit used)"),
|
|
3272
|
-
totalLines:
|
|
3110
|
+
totalLines: zod.z.number().optional().describe("Total number of lines in the file")
|
|
3273
3111
|
}),
|
|
3274
3112
|
execute: async ({ path: path4, encoding, offset, limit, showLineNumbers }) => {
|
|
3275
3113
|
const effectiveEncoding = encoding ?? "utf-8";
|
|
@@ -3316,15 +3154,15 @@ function createWorkspaceTools(workspace) {
|
|
|
3316
3154
|
id: WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE,
|
|
3317
3155
|
description: "Write content to a file in the workspace filesystem. Creates parent directories if needed.",
|
|
3318
3156
|
requireApproval: writeFileConfig.requireApproval,
|
|
3319
|
-
inputSchema:
|
|
3320
|
-
path:
|
|
3321
|
-
content:
|
|
3322
|
-
overwrite:
|
|
3157
|
+
inputSchema: zod.z.object({
|
|
3158
|
+
path: zod.z.string().describe('The path where to write the file (e.g., "/data/output.txt")'),
|
|
3159
|
+
content: zod.z.string().describe("The content to write to the file"),
|
|
3160
|
+
overwrite: zod.z.boolean().optional().default(true).describe("Whether to overwrite the file if it already exists")
|
|
3323
3161
|
}),
|
|
3324
|
-
outputSchema:
|
|
3325
|
-
success:
|
|
3326
|
-
path:
|
|
3327
|
-
size:
|
|
3162
|
+
outputSchema: zod.z.object({
|
|
3163
|
+
success: zod.z.boolean(),
|
|
3164
|
+
path: zod.z.string().describe("The path where the file was written"),
|
|
3165
|
+
size: zod.z.number().describe("The size of the written content in bytes")
|
|
3328
3166
|
}),
|
|
3329
3167
|
execute: async ({ path: path4, content, overwrite }) => {
|
|
3330
3168
|
if (readTracker && writeFileConfig.requireReadBeforeWrite) {
|
|
@@ -3357,17 +3195,17 @@ function createWorkspaceTools(workspace) {
|
|
|
3357
3195
|
id: WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE,
|
|
3358
3196
|
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.",
|
|
3359
3197
|
requireApproval: editFileConfig.requireApproval,
|
|
3360
|
-
inputSchema:
|
|
3361
|
-
path:
|
|
3362
|
-
old_string:
|
|
3363
|
-
new_string:
|
|
3364
|
-
replace_all:
|
|
3198
|
+
inputSchema: zod.z.object({
|
|
3199
|
+
path: zod.z.string().describe("The path to the file to edit"),
|
|
3200
|
+
old_string: zod.z.string().describe("The exact text to find and replace. Must be unique in the file."),
|
|
3201
|
+
new_string: zod.z.string().describe("The text to replace old_string with"),
|
|
3202
|
+
replace_all: zod.z.boolean().optional().default(false).describe("If true, replace all occurrences. If false (default), old_string must be unique.")
|
|
3365
3203
|
}),
|
|
3366
|
-
outputSchema:
|
|
3367
|
-
success:
|
|
3368
|
-
path:
|
|
3369
|
-
replacements:
|
|
3370
|
-
error:
|
|
3204
|
+
outputSchema: zod.z.object({
|
|
3205
|
+
success: zod.z.boolean(),
|
|
3206
|
+
path: zod.z.string().describe("The path to the edited file"),
|
|
3207
|
+
replacements: zod.z.number().describe("Number of replacements made"),
|
|
3208
|
+
error: zod.z.string().optional().describe("Error message if the edit failed")
|
|
3371
3209
|
}),
|
|
3372
3210
|
execute: async ({ path: path4, old_string, new_string, replace_all }) => {
|
|
3373
3211
|
try {
|
|
@@ -3437,26 +3275,26 @@ Examples:
|
|
|
3437
3275
|
- Directories only: { path: "/", dirsOnly: true }
|
|
3438
3276
|
- Exclude node_modules: { path: "/", exclude: "node_modules" }`,
|
|
3439
3277
|
requireApproval: listFilesConfig.requireApproval,
|
|
3440
|
-
inputSchema:
|
|
3441
|
-
path:
|
|
3442
|
-
maxDepth:
|
|
3443
|
-
showHidden:
|
|
3444
|
-
dirsOnly:
|
|
3445
|
-
exclude:
|
|
3446
|
-
extension:
|
|
3278
|
+
inputSchema: zod.z.object({
|
|
3279
|
+
path: zod.z.string().default("/").describe("Directory path to list"),
|
|
3280
|
+
maxDepth: zod.z.number().optional().default(3).describe("Maximum depth to descend (default: 3). Similar to tree -L flag."),
|
|
3281
|
+
showHidden: zod.z.boolean().optional().default(false).describe('Show hidden files starting with "." (default: false). Similar to tree -a flag.'),
|
|
3282
|
+
dirsOnly: zod.z.boolean().optional().default(false).describe("List directories only, no files (default: false). Similar to tree -d flag."),
|
|
3283
|
+
exclude: zod.z.string().optional().describe('Pattern to exclude (e.g., "node_modules"). Similar to tree -I flag.'),
|
|
3284
|
+
extension: zod.z.string().optional().describe('Filter by file extension (e.g., ".ts"). Similar to tree -P flag.')
|
|
3447
3285
|
}),
|
|
3448
|
-
outputSchema:
|
|
3449
|
-
tree:
|
|
3450
|
-
summary:
|
|
3451
|
-
metadata:
|
|
3452
|
-
workspace:
|
|
3453
|
-
id:
|
|
3454
|
-
name:
|
|
3286
|
+
outputSchema: zod.z.object({
|
|
3287
|
+
tree: zod.z.string().describe("Tree-style directory listing"),
|
|
3288
|
+
summary: zod.z.string().describe('Summary of directories and files (e.g., "3 directories, 12 files")'),
|
|
3289
|
+
metadata: zod.z.object({
|
|
3290
|
+
workspace: zod.z.object({
|
|
3291
|
+
id: zod.z.string().optional(),
|
|
3292
|
+
name: zod.z.string().optional()
|
|
3455
3293
|
}).optional(),
|
|
3456
|
-
filesystem:
|
|
3457
|
-
id:
|
|
3458
|
-
name:
|
|
3459
|
-
provider:
|
|
3294
|
+
filesystem: zod.z.object({
|
|
3295
|
+
id: zod.z.string().optional(),
|
|
3296
|
+
name: zod.z.string().optional(),
|
|
3297
|
+
provider: zod.z.string().optional()
|
|
3460
3298
|
}).optional()
|
|
3461
3299
|
}).optional().describe("Metadata about the workspace and filesystem")
|
|
3462
3300
|
}),
|
|
@@ -3494,15 +3332,15 @@ Examples:
|
|
|
3494
3332
|
id: WORKSPACE_TOOLS.FILESYSTEM.DELETE,
|
|
3495
3333
|
description: "Delete a file or directory from the workspace filesystem",
|
|
3496
3334
|
requireApproval: deleteConfig.requireApproval,
|
|
3497
|
-
inputSchema:
|
|
3498
|
-
path:
|
|
3499
|
-
recursive:
|
|
3335
|
+
inputSchema: zod.z.object({
|
|
3336
|
+
path: zod.z.string().describe("The path to the file or directory to delete"),
|
|
3337
|
+
recursive: zod.z.boolean().optional().default(false).describe(
|
|
3500
3338
|
"If true, delete directories and their contents recursively. Required for non-empty directories."
|
|
3501
3339
|
)
|
|
3502
3340
|
}),
|
|
3503
|
-
outputSchema:
|
|
3504
|
-
success:
|
|
3505
|
-
path:
|
|
3341
|
+
outputSchema: zod.z.object({
|
|
3342
|
+
success: zod.z.boolean(),
|
|
3343
|
+
path: zod.z.string()
|
|
3506
3344
|
}),
|
|
3507
3345
|
execute: async ({ path: path4, recursive }) => {
|
|
3508
3346
|
const stat3 = await workspace.filesystem.stat(path4);
|
|
@@ -3521,14 +3359,14 @@ Examples:
|
|
|
3521
3359
|
id: WORKSPACE_TOOLS.FILESYSTEM.FILE_STAT,
|
|
3522
3360
|
description: "Get file or directory metadata from the workspace. Returns existence, type, size, and modification time.",
|
|
3523
3361
|
requireApproval: fileStatConfig.requireApproval,
|
|
3524
|
-
inputSchema:
|
|
3525
|
-
path:
|
|
3362
|
+
inputSchema: zod.z.object({
|
|
3363
|
+
path: zod.z.string().describe("The path to check")
|
|
3526
3364
|
}),
|
|
3527
|
-
outputSchema:
|
|
3528
|
-
exists:
|
|
3529
|
-
type:
|
|
3530
|
-
size:
|
|
3531
|
-
modifiedAt:
|
|
3365
|
+
outputSchema: zod.z.object({
|
|
3366
|
+
exists: zod.z.boolean().describe("Whether the path exists"),
|
|
3367
|
+
type: zod.z.enum(["file", "directory", "none"]).describe("The type of the path if it exists"),
|
|
3368
|
+
size: zod.z.number().optional().describe("Size in bytes (for files)"),
|
|
3369
|
+
modifiedAt: zod.z.string().optional().describe("Last modification time (ISO string)")
|
|
3532
3370
|
}),
|
|
3533
3371
|
execute: async ({ path: path4 }) => {
|
|
3534
3372
|
try {
|
|
@@ -3554,13 +3392,13 @@ Examples:
|
|
|
3554
3392
|
id: WORKSPACE_TOOLS.FILESYSTEM.MKDIR,
|
|
3555
3393
|
description: "Create a directory in the workspace filesystem",
|
|
3556
3394
|
requireApproval: mkdirConfig.requireApproval,
|
|
3557
|
-
inputSchema:
|
|
3558
|
-
path:
|
|
3559
|
-
recursive:
|
|
3395
|
+
inputSchema: zod.z.object({
|
|
3396
|
+
path: zod.z.string().describe("The path of the directory to create"),
|
|
3397
|
+
recursive: zod.z.boolean().optional().default(true).describe("Whether to create parent directories if they do not exist")
|
|
3560
3398
|
}),
|
|
3561
|
-
outputSchema:
|
|
3562
|
-
success:
|
|
3563
|
-
path:
|
|
3399
|
+
outputSchema: zod.z.object({
|
|
3400
|
+
success: zod.z.boolean(),
|
|
3401
|
+
path: zod.z.string()
|
|
3564
3402
|
}),
|
|
3565
3403
|
execute: async ({ path: path4, recursive }) => {
|
|
3566
3404
|
await workspace.filesystem.mkdir(path4, { recursive });
|
|
@@ -3576,26 +3414,26 @@ Examples:
|
|
|
3576
3414
|
id: WORKSPACE_TOOLS.SEARCH.SEARCH,
|
|
3577
3415
|
description: "Search indexed content in the workspace. Supports keyword (BM25), semantic (vector), and hybrid search modes.",
|
|
3578
3416
|
requireApproval: searchConfig.requireApproval,
|
|
3579
|
-
inputSchema:
|
|
3580
|
-
query:
|
|
3581
|
-
topK:
|
|
3582
|
-
mode:
|
|
3583
|
-
minScore:
|
|
3417
|
+
inputSchema: zod.z.object({
|
|
3418
|
+
query: zod.z.string().describe("The search query string"),
|
|
3419
|
+
topK: zod.z.number().optional().default(5).describe("Maximum number of results to return"),
|
|
3420
|
+
mode: zod.z.enum(["bm25", "vector", "hybrid"]).optional().describe("Search mode: bm25 for keyword search, vector for semantic search, hybrid for both combined"),
|
|
3421
|
+
minScore: zod.z.number().optional().describe("Minimum score threshold (0-1 for normalized scores)")
|
|
3584
3422
|
}),
|
|
3585
|
-
outputSchema:
|
|
3586
|
-
results:
|
|
3587
|
-
|
|
3588
|
-
id:
|
|
3589
|
-
content:
|
|
3590
|
-
score:
|
|
3591
|
-
lineRange:
|
|
3592
|
-
start:
|
|
3593
|
-
end:
|
|
3423
|
+
outputSchema: zod.z.object({
|
|
3424
|
+
results: zod.z.array(
|
|
3425
|
+
zod.z.object({
|
|
3426
|
+
id: zod.z.string().describe("Document/file path"),
|
|
3427
|
+
content: zod.z.string().describe("The matching content"),
|
|
3428
|
+
score: zod.z.number().describe("Relevance score"),
|
|
3429
|
+
lineRange: zod.z.object({
|
|
3430
|
+
start: zod.z.number(),
|
|
3431
|
+
end: zod.z.number()
|
|
3594
3432
|
}).optional().describe("Line range where query terms were found")
|
|
3595
3433
|
})
|
|
3596
3434
|
),
|
|
3597
|
-
count:
|
|
3598
|
-
mode:
|
|
3435
|
+
count: zod.z.number().describe("Number of results returned"),
|
|
3436
|
+
mode: zod.z.string().describe("The search mode that was used")
|
|
3599
3437
|
}),
|
|
3600
3438
|
execute: async ({ query, topK, mode, minScore }) => {
|
|
3601
3439
|
const results = await workspace.search(query, {
|
|
@@ -3622,14 +3460,14 @@ Examples:
|
|
|
3622
3460
|
id: WORKSPACE_TOOLS.SEARCH.INDEX,
|
|
3623
3461
|
description: "Index content for search. The path becomes the document ID in search results.",
|
|
3624
3462
|
requireApproval: indexConfig.requireApproval,
|
|
3625
|
-
inputSchema:
|
|
3626
|
-
path:
|
|
3627
|
-
content:
|
|
3628
|
-
metadata:
|
|
3463
|
+
inputSchema: zod.z.object({
|
|
3464
|
+
path: zod.z.string().describe("The document ID/path for search results"),
|
|
3465
|
+
content: zod.z.string().describe("The text content to index"),
|
|
3466
|
+
metadata: zod.z.record(zod.z.unknown()).optional().describe("Optional metadata to store with the document")
|
|
3629
3467
|
}),
|
|
3630
|
-
outputSchema:
|
|
3631
|
-
success:
|
|
3632
|
-
path:
|
|
3468
|
+
outputSchema: zod.z.object({
|
|
3469
|
+
success: zod.z.boolean(),
|
|
3470
|
+
path: zod.z.string().describe("The indexed document ID")
|
|
3633
3471
|
}),
|
|
3634
3472
|
execute: async ({ path: path4, content, metadata }) => {
|
|
3635
3473
|
await workspace.index(path4, content, { metadata });
|
|
@@ -3647,20 +3485,20 @@ Examples:
|
|
|
3647
3485
|
id: WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND,
|
|
3648
3486
|
description: `Execute a shell command in the workspace sandbox. The output (stdout/stderr) is displayed to the user automatically in the tool result. ${pathInfo}`,
|
|
3649
3487
|
requireApproval: executeCommandConfig.requireApproval,
|
|
3650
|
-
inputSchema:
|
|
3651
|
-
command:
|
|
3652
|
-
args:
|
|
3653
|
-
timeout:
|
|
3488
|
+
inputSchema: zod.z.object({
|
|
3489
|
+
command: zod.z.string().describe('The command to execute (e.g., "ls", "npm", "python")'),
|
|
3490
|
+
args: zod.z.array(zod.z.string()).nullish().default([]).describe("Arguments to pass to the command"),
|
|
3491
|
+
timeout: zod.z.number().nullish().default(3e4).describe(
|
|
3654
3492
|
"Maximum execution time in milliseconds. Default is 30000 (30 seconds). Example: 60000 for 1 minute."
|
|
3655
3493
|
),
|
|
3656
|
-
cwd:
|
|
3494
|
+
cwd: zod.z.string().nullish().describe("Working directory for the command")
|
|
3657
3495
|
}),
|
|
3658
|
-
outputSchema:
|
|
3659
|
-
success:
|
|
3660
|
-
stdout:
|
|
3661
|
-
stderr:
|
|
3662
|
-
exitCode:
|
|
3663
|
-
executionTimeMs:
|
|
3496
|
+
outputSchema: zod.z.object({
|
|
3497
|
+
success: zod.z.boolean().describe("Whether the command executed successfully (exit code 0)"),
|
|
3498
|
+
stdout: zod.z.string().describe("Standard output from the command"),
|
|
3499
|
+
stderr: zod.z.string().describe("Standard error output"),
|
|
3500
|
+
exitCode: zod.z.number().describe("Exit code (0 = success)"),
|
|
3501
|
+
executionTimeMs: zod.z.number().describe("How long the execution took in milliseconds")
|
|
3664
3502
|
}),
|
|
3665
3503
|
execute: async ({ command, args, timeout, cwd }, context) => {
|
|
3666
3504
|
const getExecutionMetadata = () => ({
|
|
@@ -3761,5 +3599,5 @@ exports.extractLines = extractLines;
|
|
|
3761
3599
|
exports.getRecommendedIsolation = getRecommendedIsolation;
|
|
3762
3600
|
exports.isIsolationAvailable = isIsolationAvailable;
|
|
3763
3601
|
exports.resolveToolConfig = resolveToolConfig;
|
|
3764
|
-
//# sourceMappingURL=chunk-
|
|
3765
|
-
//# sourceMappingURL=chunk-
|
|
3602
|
+
//# sourceMappingURL=chunk-RYVRCT7Z.cjs.map
|
|
3603
|
+
//# sourceMappingURL=chunk-RYVRCT7Z.cjs.map
|