@agent-native/core 0.49.18 → 0.49.20

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.
Files changed (37) hide show
  1. package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
  2. package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
  3. package/dist/cli/pr-visual-recap-workflow.js +1 -1
  4. package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
  5. package/dist/cli/recap.d.ts +5 -8
  6. package/dist/cli/recap.d.ts.map +1 -1
  7. package/dist/cli/recap.js +34 -16
  8. package/dist/cli/recap.js.map +1 -1
  9. package/dist/client/blocks/library/annotation-rail.js +5 -5
  10. package/dist/client/blocks/library/annotation-rail.js.map +1 -1
  11. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  12. package/dist/client/resources/ResourcesPanel.js +16 -3
  13. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  14. package/dist/local-artifacts/index.d.ts +37 -0
  15. package/dist/local-artifacts/index.d.ts.map +1 -1
  16. package/dist/local-artifacts/index.js +380 -0
  17. package/dist/local-artifacts/index.js.map +1 -1
  18. package/dist/resources/handlers.d.ts.map +1 -1
  19. package/dist/resources/handlers.js +20 -6
  20. package/dist/resources/handlers.js.map +1 -1
  21. package/dist/resources/metadata.d.ts.map +1 -1
  22. package/dist/resources/metadata.js +5 -1
  23. package/dist/resources/metadata.js.map +1 -1
  24. package/dist/resources/store.d.ts +4 -0
  25. package/dist/resources/store.d.ts.map +1 -1
  26. package/dist/resources/store.js +143 -6
  27. package/dist/resources/store.js.map +1 -1
  28. package/dist/scripts/resources/delete.d.ts.map +1 -1
  29. package/dist/scripts/resources/delete.js +9 -3
  30. package/dist/scripts/resources/delete.js.map +1 -1
  31. package/dist/scripts/resources/write.d.ts.map +1 -1
  32. package/dist/scripts/resources/write.js +9 -3
  33. package/dist/scripts/resources/write.js.map +1 -1
  34. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  35. package/dist/server/agent-chat-plugin.js +6 -5
  36. package/dist/server/agent-chat-plugin.js.map +1 -1
  37. package/package.json +1 -1
@@ -85,6 +85,29 @@ export interface WriteLocalArtifactFileOptions extends LocalArtifactOptions {
85
85
  expectedHash?: string | null;
86
86
  ifNotExists?: boolean;
87
87
  }
88
+ export interface LocalWorkspaceResourceMeta {
89
+ id: string;
90
+ path: string;
91
+ absolutePath: string;
92
+ mimeType: string;
93
+ sizeBytes: number;
94
+ hash: string;
95
+ createdAt: string;
96
+ updatedAt: string;
97
+ mtimeMs: number;
98
+ }
99
+ export interface LocalWorkspaceResourceFile extends LocalWorkspaceResourceMeta {
100
+ content: string;
101
+ }
102
+ export interface LocalWorkspaceResourceOptions extends LoadAgentNativeManifestOptions {
103
+ }
104
+ export interface WriteLocalWorkspaceResourceOptions extends LocalWorkspaceResourceOptions {
105
+ path: string;
106
+ content: string;
107
+ expectedHash?: string | null;
108
+ ifNotExists?: boolean;
109
+ }
110
+ export declare const LOCAL_WORKSPACE_RESOURCE_ID_PREFIX = "local-workspace-resource:";
88
111
  export declare function findAgentNativeManifest(startDir?: string): string | null;
89
112
  export declare function loadAgentNativeManifest(options?: LoadAgentNativeManifestOptions): Promise<LoadedAgentNativeManifest | null>;
90
113
  export declare function resolveAgentNativeDataMode(options?: ResolveAgentNativeModeOptions): Promise<AgentNativeDataMode>;
@@ -102,4 +125,18 @@ export declare function deleteLocalArtifactFile(options: LocalArtifactOptions &
102
125
  }): Promise<boolean>;
103
126
  export declare function ensureLocalArtifactRoot(options: LocalArtifactOptions): Promise<LoadedLocalArtifactRoot>;
104
127
  export declare function createTempWorkspaceDir(prefix?: string): string;
128
+ export declare function isLocalWorkspaceResourcesEnabled(options?: LocalWorkspaceResourceOptions): Promise<boolean>;
129
+ export declare function localWorkspaceResourceId(resourcePath: string): string;
130
+ export declare function isLocalWorkspaceResourceId(id: string): boolean;
131
+ export declare function localWorkspaceResourcePathFromId(id: string): string | null;
132
+ export declare function normalizeLocalWorkspaceResourcePath(resourcePath: string): string;
133
+ export declare function canUseLocalWorkspaceResourcePath(resourcePath: string): boolean;
134
+ export declare function listLocalWorkspaceResources(options?: LocalWorkspaceResourceOptions): Promise<LocalWorkspaceResourceMeta[]>;
135
+ export declare function readLocalWorkspaceResource(options: LocalWorkspaceResourceOptions & {
136
+ path: string;
137
+ }): Promise<LocalWorkspaceResourceFile | null>;
138
+ export declare function writeLocalWorkspaceResource(options: WriteLocalWorkspaceResourceOptions): Promise<LocalWorkspaceResourceMeta>;
139
+ export declare function deleteLocalWorkspaceResource(options: LocalWorkspaceResourceOptions & {
140
+ path: string;
141
+ }): Promise<boolean>;
105
142
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/local-artifacts/index.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,aAAa,CAAC;AAE7D,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,KAAK,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,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,OAAO,CAAC,CAqBlB"}
@@ -20,6 +20,35 @@ const DEFAULT_HIDE_PATTERNS = [
20
20
  "**/dist/**",
21
21
  "**/build/**",
22
22
  ];
23
+ export const LOCAL_WORKSPACE_RESOURCE_ID_PREFIX = "local-workspace-resource:";
24
+ const LOCAL_WORKSPACE_RESOURCE_MAX_BYTES = 2 * 1024 * 1024;
25
+ const LOCAL_WORKSPACE_CONTROL_FILES = new Set([
26
+ "AGENTS.md",
27
+ "agent-native.json",
28
+ "mcp.config.json",
29
+ ".mcp.json",
30
+ ]);
31
+ const LOCAL_WORKSPACE_SKILL_ROOTS = [".agents/skills", ".agent/skills"];
32
+ const LOCAL_WORKSPACE_TEXT_EXTENSIONS = new Set([
33
+ ".css",
34
+ ".csv",
35
+ ".html",
36
+ ".js",
37
+ ".json",
38
+ ".jsx",
39
+ ".md",
40
+ ".mdx",
41
+ ".py",
42
+ ".sh",
43
+ ".sql",
44
+ ".toml",
45
+ ".ts",
46
+ ".tsx",
47
+ ".txt",
48
+ ".xml",
49
+ ".yaml",
50
+ ".yml",
51
+ ]);
23
52
  function isRecord(value) {
24
53
  return !!value && typeof value === "object" && !Array.isArray(value);
25
54
  }
@@ -529,4 +558,355 @@ export async function ensureLocalArtifactRoot(options) {
529
558
  export function createTempWorkspaceDir(prefix = "agent-native-local-") {
530
559
  return fsSync.mkdtempSync(path.join(os.tmpdir(), prefix));
531
560
  }
561
+ function localWorkspaceResourcesEnabled(loaded) {
562
+ const explicitMode = envMode();
563
+ if (explicitMode) {
564
+ assertLocalFilesRuntimeAllowed(explicitMode);
565
+ return explicitMode === "local-files";
566
+ }
567
+ const manifest = loaded?.manifest;
568
+ const mode = manifest?.mode;
569
+ if (mode) {
570
+ assertLocalFilesRuntimeAllowed(mode);
571
+ if (mode === "local-files")
572
+ return true;
573
+ }
574
+ return false;
575
+ }
576
+ async function resolveLocalWorkspaceRoot(options = {}) {
577
+ const loaded = await loadAgentNativeManifest({ ...options, optional: true });
578
+ if (localWorkspaceResourcesEnabled(loaded)) {
579
+ return loaded?.rootDir ?? path.resolve(options.cwd ?? process.cwd());
580
+ }
581
+ return null;
582
+ }
583
+ export async function isLocalWorkspaceResourcesEnabled(options = {}) {
584
+ return !!(await resolveLocalWorkspaceRoot(options));
585
+ }
586
+ export function localWorkspaceResourceId(resourcePath) {
587
+ const normalized = normalizeSlash(resourcePath).replace(/^\/+/, "");
588
+ return `${LOCAL_WORKSPACE_RESOURCE_ID_PREFIX}${Buffer.from(normalized, "utf8").toString("base64url")}`;
589
+ }
590
+ export function isLocalWorkspaceResourceId(id) {
591
+ return id.startsWith(LOCAL_WORKSPACE_RESOURCE_ID_PREFIX);
592
+ }
593
+ export function localWorkspaceResourcePathFromId(id) {
594
+ if (!isLocalWorkspaceResourceId(id))
595
+ return null;
596
+ const encoded = id.slice(LOCAL_WORKSPACE_RESOURCE_ID_PREFIX.length);
597
+ try {
598
+ const decoded = Buffer.from(encoded, "base64url").toString("utf8");
599
+ return normalizeLocalWorkspaceResourcePath(decoded);
600
+ }
601
+ catch {
602
+ return null;
603
+ }
604
+ }
605
+ function mimeTypeForLocalWorkspaceResource(resourcePath) {
606
+ const extension = extensionOf(resourcePath);
607
+ if (extension === ".md")
608
+ return "text/markdown";
609
+ if (extension === ".mdx")
610
+ return "text/mdx";
611
+ if (extension === ".json")
612
+ return "application/json";
613
+ if (extension === ".yaml" || extension === ".yml")
614
+ return "application/yaml";
615
+ if (extension === ".toml")
616
+ return "text/toml";
617
+ if (extension === ".ts" || extension === ".tsx")
618
+ return "text/typescript";
619
+ if (extension === ".js" || extension === ".jsx")
620
+ return "text/javascript";
621
+ if (extension === ".html")
622
+ return "text/html";
623
+ if (extension === ".css")
624
+ return "text/css";
625
+ if (extension === ".xml")
626
+ return "application/xml";
627
+ if (extension === ".csv")
628
+ return "text/csv";
629
+ if (extension === ".sql")
630
+ return "text/sql";
631
+ if (extension === ".sh")
632
+ return "text/x-shellscript";
633
+ if (extension === ".py")
634
+ return "text/x-python";
635
+ return "text/plain";
636
+ }
637
+ function isSupportedLocalWorkspaceTextFile(resourcePath) {
638
+ return LOCAL_WORKSPACE_TEXT_EXTENSIONS.has(extensionOf(resourcePath));
639
+ }
640
+ export function normalizeLocalWorkspaceResourcePath(resourcePath) {
641
+ const safePath = normalizeRelativePath(normalizeSlash(resourcePath).replace(/^\/+/, ""), "resource path");
642
+ if (LOCAL_WORKSPACE_CONTROL_FILES.has(safePath))
643
+ return safePath;
644
+ if (safePath.startsWith(".agents/skills/")) {
645
+ const relativeSkillPath = normalizeRelativePath(safePath.slice(".agents/skills/".length), "resource path");
646
+ return normalizeSlash(path.posix.join("skills", relativeSkillPath));
647
+ }
648
+ if (safePath.startsWith(".agent/skills/")) {
649
+ const relativeSkillPath = normalizeRelativePath(safePath.slice(".agent/skills/".length), "resource path");
650
+ return normalizeSlash(path.posix.join("skills", relativeSkillPath));
651
+ }
652
+ if (safePath.startsWith("skills/"))
653
+ return safePath;
654
+ throw new Error(`Local workspace resource "${resourcePath}" must be AGENTS.md, agent-native.json, mcp.config.json, .mcp.json, or under skills/.`);
655
+ }
656
+ export function canUseLocalWorkspaceResourcePath(resourcePath) {
657
+ try {
658
+ normalizeLocalWorkspaceResourcePath(resourcePath);
659
+ return true;
660
+ }
661
+ catch {
662
+ return false;
663
+ }
664
+ }
665
+ function localWorkspaceResourceAbsolutePath(workspaceRoot, resourcePath, options = {}) {
666
+ const normalized = normalizeLocalWorkspaceResourcePath(resourcePath);
667
+ const safePath = normalizeRelativePath(normalizeSlash(resourcePath).replace(/^\/+/, ""), "resource path");
668
+ let relativePath = normalized;
669
+ if (safePath.startsWith(".agents/skills/") ||
670
+ safePath.startsWith(".agent/skills/")) {
671
+ relativePath = safePath;
672
+ }
673
+ else if (normalized.startsWith("skills/")) {
674
+ const skillPath = normalized.slice("skills/".length);
675
+ const candidates = LOCAL_WORKSPACE_SKILL_ROOTS.map((root) => normalizeSlash(path.posix.join(root, skillPath)));
676
+ relativePath = candidates[0];
677
+ if (options.preferExisting) {
678
+ relativePath =
679
+ candidates.find((candidate) => fsSync.existsSync(path.resolve(workspaceRoot, candidate))) ?? relativePath;
680
+ }
681
+ }
682
+ const { absolutePath } = resolveInsideWorkspace(workspaceRoot, relativePath);
683
+ return { resourcePath: normalized, absolutePath };
684
+ }
685
+ function localWorkspaceResourceDeletePaths(workspaceRoot, resourcePath) {
686
+ const normalized = normalizeLocalWorkspaceResourcePath(resourcePath);
687
+ const safePath = normalizeRelativePath(normalizeSlash(resourcePath).replace(/^\/+/, ""), "resource path");
688
+ if (safePath.startsWith(".agents/skills/") ||
689
+ safePath.startsWith(".agent/skills/") ||
690
+ !normalized.startsWith("skills/")) {
691
+ const { absolutePath } = localWorkspaceResourceAbsolutePath(workspaceRoot, resourcePath);
692
+ return [absolutePath];
693
+ }
694
+ const skillPath = normalized.slice("skills/".length);
695
+ return LOCAL_WORKSPACE_SKILL_ROOTS.map((root) => {
696
+ const relativePath = normalizeSlash(path.posix.join(root, skillPath));
697
+ return resolveInsideWorkspace(workspaceRoot, relativePath).absolutePath;
698
+ });
699
+ }
700
+ function assertNoSymlinkAbsolutePathSync(workspaceRoot, absolutePath, options = {}) {
701
+ const relative = path.relative(workspaceRoot, absolutePath);
702
+ const segments = relative.split(path.sep).filter(Boolean);
703
+ let current = workspaceRoot;
704
+ const pathsToCheck = [
705
+ current,
706
+ ...segments.map((segment) => {
707
+ current = path.join(current, segment);
708
+ return current;
709
+ }),
710
+ ];
711
+ for (let index = 0; index < pathsToCheck.length; index += 1) {
712
+ const candidate = pathsToCheck[index];
713
+ try {
714
+ const stat = fsSync.lstatSync(candidate);
715
+ if (stat.isSymbolicLink()) {
716
+ throw new Error(`Path "${candidate}" must not traverse a symlink`);
717
+ }
718
+ if (index < pathsToCheck.length - 1 && !stat.isDirectory()) {
719
+ throw new Error(`Path "${candidate}" is not a directory`);
720
+ }
721
+ }
722
+ catch (error) {
723
+ if (errorCode(error) === "ENOENT" && options.allowMissingLeaf)
724
+ return;
725
+ throw error;
726
+ }
727
+ }
728
+ }
729
+ function readLocalWorkspaceTextFile(workspaceRoot, absolutePath) {
730
+ assertNoSymlinkAbsolutePathSync(workspaceRoot, absolutePath);
731
+ const fd = fsSync.openSync(absolutePath, noFollowOpenFlags());
732
+ try {
733
+ const stat = fsSync.fstatSync(fd);
734
+ if (!stat.isFile()) {
735
+ throw new Error(`Path "${absolutePath}" is not a file`);
736
+ }
737
+ if (stat.size > LOCAL_WORKSPACE_RESOURCE_MAX_BYTES) {
738
+ throw new Error(`Local workspace resource "${absolutePath}" is too large to load`);
739
+ }
740
+ return {
741
+ content: fsSync.readFileSync(fd, "utf8"),
742
+ stat,
743
+ };
744
+ }
745
+ finally {
746
+ fsSync.closeSync(fd);
747
+ }
748
+ }
749
+ function localWorkspaceResourceMeta(resourcePath, absolutePath, content, stat) {
750
+ return {
751
+ id: localWorkspaceResourceId(resourcePath),
752
+ path: resourcePath,
753
+ absolutePath,
754
+ mimeType: mimeTypeForLocalWorkspaceResource(resourcePath),
755
+ sizeBytes: Buffer.byteLength(content, "utf8"),
756
+ hash: hashContent(content),
757
+ createdAt: stat.birthtime.toISOString(),
758
+ updatedAt: stat.mtime.toISOString(),
759
+ mtimeMs: stat.mtimeMs,
760
+ };
761
+ }
762
+ async function maybeLocalWorkspaceResourceMeta(workspaceRoot, resourcePath, absolutePath) {
763
+ if (!isSupportedLocalWorkspaceTextFile(resourcePath))
764
+ return null;
765
+ try {
766
+ const { content, stat } = readLocalWorkspaceTextFile(workspaceRoot, absolutePath);
767
+ return localWorkspaceResourceMeta(resourcePath, absolutePath, content, stat);
768
+ }
769
+ catch (error) {
770
+ if (errorCode(error) === "ENOENT")
771
+ return null;
772
+ throw error;
773
+ }
774
+ }
775
+ async function walkLocalWorkspaceSkillRoot(workspaceRoot, skillRoot, seenPaths) {
776
+ const absoluteRoot = path.join(workspaceRoot, skillRoot);
777
+ try {
778
+ assertNoSymlinkAbsolutePathSync(workspaceRoot, absoluteRoot);
779
+ }
780
+ catch (error) {
781
+ if (errorCode(error) === "ENOENT")
782
+ return [];
783
+ throw error;
784
+ }
785
+ const files = [];
786
+ async function walk(directory) {
787
+ let entries;
788
+ try {
789
+ entries = await fs.readdir(directory, { withFileTypes: true });
790
+ }
791
+ catch (error) {
792
+ if (errorCode(error) === "ENOENT")
793
+ return;
794
+ throw error;
795
+ }
796
+ for (const entry of entries) {
797
+ if (entry.name === ".DS_Store")
798
+ continue;
799
+ const absolutePath = path.join(directory, entry.name);
800
+ const relativeToSkillRoot = normalizeSlash(path.relative(absoluteRoot, absolutePath));
801
+ const resourcePath = normalizeSlash(path.posix.join("skills", relativeToSkillRoot));
802
+ if (seenPaths.has(resourcePath))
803
+ continue;
804
+ if (entry.isDirectory()) {
805
+ await walk(absolutePath);
806
+ continue;
807
+ }
808
+ if (!entry.isFile())
809
+ continue;
810
+ const meta = await maybeLocalWorkspaceResourceMeta(workspaceRoot, resourcePath, absolutePath);
811
+ if (!meta)
812
+ continue;
813
+ seenPaths.add(resourcePath);
814
+ files.push(meta);
815
+ }
816
+ }
817
+ await walk(absoluteRoot);
818
+ return files;
819
+ }
820
+ export async function listLocalWorkspaceResources(options = {}) {
821
+ const workspaceRoot = await resolveLocalWorkspaceRoot(options);
822
+ if (!workspaceRoot)
823
+ return [];
824
+ const seenPaths = new Set();
825
+ const resources = [];
826
+ for (const resourcePath of LOCAL_WORKSPACE_CONTROL_FILES) {
827
+ const { absolutePath } = localWorkspaceResourceAbsolutePath(workspaceRoot, resourcePath);
828
+ const meta = await maybeLocalWorkspaceResourceMeta(workspaceRoot, resourcePath, absolutePath);
829
+ if (!meta)
830
+ continue;
831
+ seenPaths.add(resourcePath);
832
+ resources.push(meta);
833
+ }
834
+ for (const skillRoot of LOCAL_WORKSPACE_SKILL_ROOTS) {
835
+ resources.push(...(await walkLocalWorkspaceSkillRoot(workspaceRoot, skillRoot, seenPaths)));
836
+ }
837
+ return resources.sort((a, b) => a.path.localeCompare(b.path));
838
+ }
839
+ export async function readLocalWorkspaceResource(options) {
840
+ const workspaceRoot = await resolveLocalWorkspaceRoot(options);
841
+ if (!workspaceRoot)
842
+ return null;
843
+ const { resourcePath, absolutePath } = localWorkspaceResourceAbsolutePath(workspaceRoot, options.path, { preferExisting: true });
844
+ if (!isSupportedLocalWorkspaceTextFile(resourcePath))
845
+ return null;
846
+ try {
847
+ const { content, stat } = readLocalWorkspaceTextFile(workspaceRoot, absolutePath);
848
+ return {
849
+ ...localWorkspaceResourceMeta(resourcePath, absolutePath, content, stat),
850
+ content,
851
+ };
852
+ }
853
+ catch (error) {
854
+ if (errorCode(error) === "ENOENT")
855
+ return null;
856
+ throw error;
857
+ }
858
+ }
859
+ export async function writeLocalWorkspaceResource(options) {
860
+ const workspaceRoot = await resolveLocalWorkspaceRoot(options);
861
+ if (!workspaceRoot) {
862
+ throw new Error("Local file mode is not enabled");
863
+ }
864
+ const { resourcePath, absolutePath } = localWorkspaceResourceAbsolutePath(workspaceRoot, options.path, { preferExisting: true });
865
+ if (!isSupportedLocalWorkspaceTextFile(resourcePath)) {
866
+ throw new Error(`Local workspace resource "${resourcePath}" is not text`);
867
+ }
868
+ return withWriteLock(absolutePath, async () => {
869
+ const existing = await readLocalWorkspaceResource({
870
+ ...options,
871
+ path: resourcePath,
872
+ });
873
+ if (options.ifNotExists && existing) {
874
+ throw new Error(`File "${resourcePath}" already exists`);
875
+ }
876
+ if (options.expectedHash &&
877
+ (!existing || existing.hash !== options.expectedHash)) {
878
+ throw new Error(`File "${resourcePath}" changed on disk. Reload before saving again.`);
879
+ }
880
+ assertNoSymlinkAbsolutePathSync(workspaceRoot, absolutePath, {
881
+ allowMissingLeaf: true,
882
+ });
883
+ await fs.mkdir(path.dirname(absolutePath), { recursive: true });
884
+ const tempPath = path.join(path.dirname(absolutePath), `.${path.basename(absolutePath)}.${process.pid}.${crypto.randomUUID()}.tmp`);
885
+ await fs.writeFile(tempPath, options.content, "utf8");
886
+ await fs.rename(tempPath, absolutePath);
887
+ const stat = await fs.stat(absolutePath);
888
+ return localWorkspaceResourceMeta(resourcePath, absolutePath, options.content, stat);
889
+ });
890
+ }
891
+ export async function deleteLocalWorkspaceResource(options) {
892
+ const workspaceRoot = await resolveLocalWorkspaceRoot(options);
893
+ if (!workspaceRoot) {
894
+ throw new Error("Local file mode is not enabled");
895
+ }
896
+ const absolutePaths = localWorkspaceResourceDeletePaths(workspaceRoot, options.path);
897
+ let deleted = false;
898
+ for (const absolutePath of absolutePaths) {
899
+ try {
900
+ assertNoSymlinkAbsolutePathSync(workspaceRoot, absolutePath);
901
+ await fs.unlink(absolutePath);
902
+ deleted = true;
903
+ }
904
+ catch (error) {
905
+ if (errorCode(error) === "ENOENT")
906
+ continue;
907
+ throw error;
908
+ }
909
+ }
910
+ return deleted;
911
+ }
532
912
  //# sourceMappingURL=index.js.map