@ash-cloud/ash-ai 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +65 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -9
- package/dist/index.d.ts +81 -9
- package/dist/index.js +65 -33
- package/dist/index.js.map +1 -1
- package/dist/playground.js +1275 -1126
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6021,6 +6021,7 @@ var init_sandbox_file_watcher = __esm({
|
|
|
6021
6021
|
type,
|
|
6022
6022
|
relativePath,
|
|
6023
6023
|
absolutePath,
|
|
6024
|
+
basePath: this.watchPath,
|
|
6024
6025
|
sessionId: this.sessionId,
|
|
6025
6026
|
fileSize,
|
|
6026
6027
|
timestamp: /* @__PURE__ */ new Date()
|
|
@@ -6229,6 +6230,7 @@ var init_sandbox_file_watcher = __esm({
|
|
|
6229
6230
|
type: "add",
|
|
6230
6231
|
relativePath: filePath,
|
|
6231
6232
|
absolutePath: `${this.basePath}/${filePath}`,
|
|
6233
|
+
basePath: this.basePath,
|
|
6232
6234
|
sessionId: this.sessionId,
|
|
6233
6235
|
fileSize: info.size,
|
|
6234
6236
|
timestamp: /* @__PURE__ */ new Date()
|
|
@@ -6241,6 +6243,7 @@ var init_sandbox_file_watcher = __esm({
|
|
|
6241
6243
|
type: "unlink",
|
|
6242
6244
|
relativePath: filePath,
|
|
6243
6245
|
absolutePath: `${this.basePath}/${filePath}`,
|
|
6246
|
+
basePath: this.basePath,
|
|
6244
6247
|
sessionId: this.sessionId,
|
|
6245
6248
|
timestamp: /* @__PURE__ */ new Date()
|
|
6246
6249
|
});
|
|
@@ -6545,7 +6548,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6545
6548
|
}
|
|
6546
6549
|
};
|
|
6547
6550
|
const webhookType = payload.event === "file_sync" ? "file_sync" : "file_change";
|
|
6548
|
-
const filePath = payload.fileSyncEvent?.
|
|
6551
|
+
const filePath = payload.fileSyncEvent?.canonicalPath ?? payload.fileChangeEvent?.relativePath;
|
|
6549
6552
|
const operation = payload.fileSyncEvent?.operation ?? payload.fileChangeEvent?.type;
|
|
6550
6553
|
if (isAsync) {
|
|
6551
6554
|
sendWithRetry(0).then(async (result) => {
|
|
@@ -6675,7 +6678,9 @@ var init_sandbox_file_sync = __esm({
|
|
|
6675
6678
|
const eventData = {
|
|
6676
6679
|
operation: event.operation,
|
|
6677
6680
|
source: event.source,
|
|
6678
|
-
|
|
6681
|
+
canonicalPath: event.canonicalPath,
|
|
6682
|
+
basePath: event.basePath,
|
|
6683
|
+
sandboxPath: event.sandboxPath,
|
|
6679
6684
|
fileSize: event.fileSize,
|
|
6680
6685
|
success: event.success,
|
|
6681
6686
|
error: event.error,
|
|
@@ -6706,6 +6711,13 @@ var init_sandbox_file_sync = __esm({
|
|
|
6706
6711
|
setSandboxOperations(ops) {
|
|
6707
6712
|
this.sandboxOps = ops;
|
|
6708
6713
|
}
|
|
6714
|
+
/**
|
|
6715
|
+
* Get the effective base path for sandbox operations
|
|
6716
|
+
* @param targetPath - Optional override for the base path
|
|
6717
|
+
*/
|
|
6718
|
+
getBasePath(targetPath) {
|
|
6719
|
+
return targetPath ?? this.sandboxBasePath;
|
|
6720
|
+
}
|
|
6709
6721
|
/**
|
|
6710
6722
|
* Get the full sandbox path for a file
|
|
6711
6723
|
* @param path - The relative file path
|
|
@@ -6713,12 +6725,30 @@ var init_sandbox_file_sync = __esm({
|
|
|
6713
6725
|
*/
|
|
6714
6726
|
getSandboxPath(path15, targetPath) {
|
|
6715
6727
|
const normalizedPath = path15.replace(/^\/+/, "");
|
|
6716
|
-
const basePath =
|
|
6728
|
+
const basePath = this.getBasePath(targetPath);
|
|
6717
6729
|
if (basePath === ".") {
|
|
6718
6730
|
return normalizedPath;
|
|
6719
6731
|
}
|
|
6720
6732
|
return `${basePath}/${normalizedPath}`;
|
|
6721
6733
|
}
|
|
6734
|
+
/**
|
|
6735
|
+
* Build all path fields for a FileSyncEvent
|
|
6736
|
+
* @param path - The canonical file path (used as S3 key)
|
|
6737
|
+
* @param targetPath - Optional override for the base path
|
|
6738
|
+
*/
|
|
6739
|
+
buildPathFields(path15, targetPath) {
|
|
6740
|
+
const normalizedPath = path15.replace(/^\/+/, "");
|
|
6741
|
+
const basePath = this.getBasePath(targetPath);
|
|
6742
|
+
const sandboxPath = this.getSandboxPath(path15, targetPath);
|
|
6743
|
+
return {
|
|
6744
|
+
canonicalPath: normalizedPath,
|
|
6745
|
+
// The logical path (S3 key)
|
|
6746
|
+
basePath,
|
|
6747
|
+
// The prefix used in sandbox
|
|
6748
|
+
sandboxPath
|
|
6749
|
+
// Full computed path in sandbox
|
|
6750
|
+
};
|
|
6751
|
+
}
|
|
6722
6752
|
/**
|
|
6723
6753
|
* Push a file: writes to S3, then to sandbox if running
|
|
6724
6754
|
* @param sessionId - Session ID
|
|
@@ -6735,13 +6765,14 @@ var init_sandbox_file_sync = __esm({
|
|
|
6735
6765
|
};
|
|
6736
6766
|
const source = options?.source ?? "client_api";
|
|
6737
6767
|
const uploadToStorageOp = source === "client_api" ? "client_uploaded_to_ash_storage" : "agent_sandbox_saved_to_ash_storage";
|
|
6768
|
+
const pathFields = this.buildPathFields(path15, options?.targetPath);
|
|
6738
6769
|
try {
|
|
6739
6770
|
await this.fileStore.writeFile(sessionId, path15, content);
|
|
6740
6771
|
result.s3Written = true;
|
|
6741
6772
|
await this.emitFileEvent(sessionId, {
|
|
6742
6773
|
operation: uploadToStorageOp,
|
|
6743
6774
|
source,
|
|
6744
|
-
|
|
6775
|
+
...pathFields,
|
|
6745
6776
|
fileSize: content.length,
|
|
6746
6777
|
success: true,
|
|
6747
6778
|
previousContent,
|
|
@@ -6754,7 +6785,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6754
6785
|
await this.emitFileEvent(sessionId, {
|
|
6755
6786
|
operation: uploadToStorageOp,
|
|
6756
6787
|
source,
|
|
6757
|
-
|
|
6788
|
+
...pathFields,
|
|
6758
6789
|
fileSize: content.length,
|
|
6759
6790
|
success: false,
|
|
6760
6791
|
error: errorMessage
|
|
@@ -6763,13 +6794,12 @@ var init_sandbox_file_sync = __esm({
|
|
|
6763
6794
|
}
|
|
6764
6795
|
if (this.sandboxOps?.isSandboxRunning(sessionId)) {
|
|
6765
6796
|
try {
|
|
6766
|
-
const
|
|
6767
|
-
const writeResult = await this.sandboxOps.writeFile(sessionId, sandboxPath, content);
|
|
6797
|
+
const writeResult = await this.sandboxOps.writeFile(sessionId, pathFields.sandboxPath, content);
|
|
6768
6798
|
result.sandboxWritten = writeResult.success;
|
|
6769
6799
|
await this.emitFileEvent(sessionId, {
|
|
6770
6800
|
operation: "ash_storage_synced_to_agent_sandbox",
|
|
6771
6801
|
source,
|
|
6772
|
-
|
|
6802
|
+
...pathFields,
|
|
6773
6803
|
fileSize: content.length,
|
|
6774
6804
|
success: writeResult.success,
|
|
6775
6805
|
error: writeResult.error
|
|
@@ -6783,7 +6813,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6783
6813
|
await this.emitFileEvent(sessionId, {
|
|
6784
6814
|
operation: "ash_storage_synced_to_agent_sandbox",
|
|
6785
6815
|
source,
|
|
6786
|
-
|
|
6816
|
+
...pathFields,
|
|
6787
6817
|
fileSize: content.length,
|
|
6788
6818
|
success: false,
|
|
6789
6819
|
error: errorMessage
|
|
@@ -6826,15 +6856,15 @@ var init_sandbox_file_sync = __esm({
|
|
|
6826
6856
|
result.error = "Sandbox is not running";
|
|
6827
6857
|
return result;
|
|
6828
6858
|
}
|
|
6859
|
+
const pathFields = this.buildPathFields(path15, options?.targetPath);
|
|
6829
6860
|
try {
|
|
6830
|
-
const
|
|
6831
|
-
const readResult = await this.sandboxOps.readFile(sessionId, sandboxPath);
|
|
6861
|
+
const readResult = await this.sandboxOps.readFile(sessionId, pathFields.sandboxPath);
|
|
6832
6862
|
if (!readResult.success || !readResult.content) {
|
|
6833
6863
|
result.error = readResult.error ?? "File not found in sandbox";
|
|
6834
6864
|
await this.emitFileEvent(sessionId, {
|
|
6835
6865
|
operation: "read_from_agent_sandbox",
|
|
6836
6866
|
source: "ash_file_sync",
|
|
6837
|
-
|
|
6867
|
+
...pathFields,
|
|
6838
6868
|
success: false,
|
|
6839
6869
|
error: result.error
|
|
6840
6870
|
});
|
|
@@ -6844,7 +6874,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6844
6874
|
await this.emitFileEvent(sessionId, {
|
|
6845
6875
|
operation: "read_from_agent_sandbox",
|
|
6846
6876
|
source: "ash_file_sync",
|
|
6847
|
-
|
|
6877
|
+
...pathFields,
|
|
6848
6878
|
fileSize: readResult.content.length,
|
|
6849
6879
|
success: true,
|
|
6850
6880
|
newContent: readResult.content
|
|
@@ -6855,7 +6885,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6855
6885
|
await this.emitFileEvent(sessionId, {
|
|
6856
6886
|
operation: "read_from_agent_sandbox",
|
|
6857
6887
|
source: "ash_file_sync",
|
|
6858
|
-
|
|
6888
|
+
...pathFields,
|
|
6859
6889
|
success: false,
|
|
6860
6890
|
error: errorMessage
|
|
6861
6891
|
});
|
|
@@ -6867,7 +6897,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6867
6897
|
await this.emitFileEvent(sessionId, {
|
|
6868
6898
|
operation: "agent_sandbox_saved_to_ash_storage",
|
|
6869
6899
|
source: "ash_file_sync",
|
|
6870
|
-
|
|
6900
|
+
...pathFields,
|
|
6871
6901
|
fileSize: result.content.length,
|
|
6872
6902
|
success: true,
|
|
6873
6903
|
newContent: result.content
|
|
@@ -6879,7 +6909,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6879
6909
|
await this.emitFileEvent(sessionId, {
|
|
6880
6910
|
operation: "agent_sandbox_saved_to_ash_storage",
|
|
6881
6911
|
source: "ash_file_sync",
|
|
6882
|
-
|
|
6912
|
+
...pathFields,
|
|
6883
6913
|
fileSize: result.content?.length,
|
|
6884
6914
|
success: false,
|
|
6885
6915
|
error: errorMessage
|
|
@@ -6921,13 +6951,14 @@ var init_sandbox_file_sync = __esm({
|
|
|
6921
6951
|
*/
|
|
6922
6952
|
async deleteFile(sessionId, path15) {
|
|
6923
6953
|
const result = { s3Deleted: false, sandboxDeleted: false };
|
|
6954
|
+
const pathFields = this.buildPathFields(path15);
|
|
6924
6955
|
try {
|
|
6925
6956
|
await this.fileStore.deleteFile(sessionId, path15);
|
|
6926
6957
|
result.s3Deleted = true;
|
|
6927
6958
|
await this.emitFileEvent(sessionId, {
|
|
6928
6959
|
operation: "deleted_from_ash_storage",
|
|
6929
6960
|
source: "ash_file_sync",
|
|
6930
|
-
|
|
6961
|
+
...pathFields,
|
|
6931
6962
|
success: true
|
|
6932
6963
|
});
|
|
6933
6964
|
} catch (error) {
|
|
@@ -6936,20 +6967,19 @@ var init_sandbox_file_sync = __esm({
|
|
|
6936
6967
|
await this.emitFileEvent(sessionId, {
|
|
6937
6968
|
operation: "deleted_from_ash_storage",
|
|
6938
6969
|
source: "ash_file_sync",
|
|
6939
|
-
|
|
6970
|
+
...pathFields,
|
|
6940
6971
|
success: false,
|
|
6941
6972
|
error: errorMessage
|
|
6942
6973
|
});
|
|
6943
6974
|
}
|
|
6944
6975
|
if (this.sandboxOps?.isSandboxRunning(sessionId)) {
|
|
6945
6976
|
try {
|
|
6946
|
-
|
|
6947
|
-
console.log(`[FILE_SYNC] Would delete ${sandboxPath} from sandbox`);
|
|
6977
|
+
console.log(`[FILE_SYNC] Would delete ${pathFields.sandboxPath} from sandbox`);
|
|
6948
6978
|
result.sandboxDeleted = true;
|
|
6949
6979
|
await this.emitFileEvent(sessionId, {
|
|
6950
6980
|
operation: "deleted_from_agent_sandbox",
|
|
6951
6981
|
source: "ash_file_sync",
|
|
6952
|
-
|
|
6982
|
+
...pathFields,
|
|
6953
6983
|
success: true
|
|
6954
6984
|
});
|
|
6955
6985
|
} catch (error) {
|
|
@@ -6957,7 +6987,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6957
6987
|
await this.emitFileEvent(sessionId, {
|
|
6958
6988
|
operation: "deleted_from_agent_sandbox",
|
|
6959
6989
|
source: "ash_file_sync",
|
|
6960
|
-
|
|
6990
|
+
...pathFields,
|
|
6961
6991
|
success: false,
|
|
6962
6992
|
error: errorMessage
|
|
6963
6993
|
});
|
|
@@ -6977,6 +7007,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
6977
7007
|
}
|
|
6978
7008
|
const files = await this.fileStore.listFiles(sessionId);
|
|
6979
7009
|
for (const file of files) {
|
|
7010
|
+
const pathFields = this.buildPathFields(file.path);
|
|
6980
7011
|
try {
|
|
6981
7012
|
const content = await this.fileStore.readFile(sessionId, file.path);
|
|
6982
7013
|
if (!content) {
|
|
@@ -6984,20 +7015,19 @@ var init_sandbox_file_sync = __esm({
|
|
|
6984
7015
|
await this.emitFileEvent(sessionId, {
|
|
6985
7016
|
operation: "ash_storage_synced_to_agent_sandbox",
|
|
6986
7017
|
source: "ash_file_sync",
|
|
6987
|
-
|
|
7018
|
+
...pathFields,
|
|
6988
7019
|
success: false,
|
|
6989
7020
|
error: "File not found in Ash storage"
|
|
6990
7021
|
});
|
|
6991
7022
|
continue;
|
|
6992
7023
|
}
|
|
6993
|
-
const
|
|
6994
|
-
const writeResult = await this.sandboxOps.writeFile(sessionId, sandboxPath, content);
|
|
7024
|
+
const writeResult = await this.sandboxOps.writeFile(sessionId, pathFields.sandboxPath, content);
|
|
6995
7025
|
if (writeResult.success) {
|
|
6996
7026
|
result.fileCount++;
|
|
6997
7027
|
await this.emitFileEvent(sessionId, {
|
|
6998
7028
|
operation: "ash_storage_synced_to_agent_sandbox",
|
|
6999
7029
|
source: "ash_file_sync",
|
|
7000
|
-
|
|
7030
|
+
...pathFields,
|
|
7001
7031
|
fileSize: content.length,
|
|
7002
7032
|
success: true
|
|
7003
7033
|
});
|
|
@@ -7006,7 +7036,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
7006
7036
|
await this.emitFileEvent(sessionId, {
|
|
7007
7037
|
operation: "ash_storage_synced_to_agent_sandbox",
|
|
7008
7038
|
source: "ash_file_sync",
|
|
7009
|
-
|
|
7039
|
+
...pathFields,
|
|
7010
7040
|
fileSize: content.length,
|
|
7011
7041
|
success: false,
|
|
7012
7042
|
error: writeResult.error
|
|
@@ -7021,7 +7051,7 @@ var init_sandbox_file_sync = __esm({
|
|
|
7021
7051
|
await this.emitFileEvent(sessionId, {
|
|
7022
7052
|
operation: "ash_storage_synced_to_agent_sandbox",
|
|
7023
7053
|
source: "ash_file_sync",
|
|
7024
|
-
|
|
7054
|
+
...pathFields,
|
|
7025
7055
|
success: false,
|
|
7026
7056
|
error: errorMessage
|
|
7027
7057
|
});
|
|
@@ -7052,24 +7082,25 @@ var init_sandbox_file_sync = __esm({
|
|
|
7052
7082
|
return result;
|
|
7053
7083
|
}
|
|
7054
7084
|
}
|
|
7055
|
-
for (const
|
|
7085
|
+
for (const file of filesToSync) {
|
|
7086
|
+
const pathFields = this.buildPathFields(file);
|
|
7056
7087
|
try {
|
|
7057
|
-
const pullResult = await this.pullFile(sessionId,
|
|
7088
|
+
const pullResult = await this.pullFile(sessionId, file);
|
|
7058
7089
|
if (pullResult.s3Written) {
|
|
7059
7090
|
result.fileCount++;
|
|
7060
7091
|
} else if (pullResult.error) {
|
|
7061
|
-
result.errors.push({ path:
|
|
7092
|
+
result.errors.push({ path: file, error: pullResult.error });
|
|
7062
7093
|
}
|
|
7063
7094
|
} catch (error) {
|
|
7064
7095
|
const errorMessage = extractErrorMessage(error);
|
|
7065
7096
|
result.errors.push({
|
|
7066
|
-
path:
|
|
7097
|
+
path: file,
|
|
7067
7098
|
error: errorMessage
|
|
7068
7099
|
});
|
|
7069
7100
|
await this.emitFileEvent(sessionId, {
|
|
7070
7101
|
operation: "agent_sandbox_saved_to_ash_storage",
|
|
7071
7102
|
source: "ash_file_sync",
|
|
7072
|
-
|
|
7103
|
+
...pathFields,
|
|
7073
7104
|
success: false,
|
|
7074
7105
|
error: errorMessage
|
|
7075
7106
|
});
|
|
@@ -7483,6 +7514,7 @@ WATCHER_EOF`;
|
|
|
7483
7514
|
type: data.type,
|
|
7484
7515
|
relativePath: data.path.replace(/^\.\//, ""),
|
|
7485
7516
|
absolutePath: data.path,
|
|
7517
|
+
basePath: this.watchPath,
|
|
7486
7518
|
sessionId: this.sessionId,
|
|
7487
7519
|
timestamp: new Date(data.timestamp)
|
|
7488
7520
|
});
|