Spaces:
Sleeping
Sleeping
File size: 3,570 Bytes
548a458 350d89b 548a458 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | // Shared message types between main thread and session worker.
export interface InitMessage {
type: "init";
sessionId: string;
cwd: string;
initialFiles: Record<string, string>;
capabilities: {
network: boolean;
python: boolean;
javascript: boolean;
};
networkConfig?: {
dangerouslyAllowFullInternetAccess: boolean;
allowedUrlPrefixes: string[];
allowedMethods: string[];
};
executionLimits: {
maxCallDepth: number;
maxCommandCount: number;
maxLoopIterations: number;
maxAwkIterations: number;
maxSedIterations: number;
};
maxSessionFsBytes: number;
maxSingleFileBytes: number;
maxWriteBatchBytes: number;
maxReadBytesPerCall: number;
maxCapturedOutputBytesExec: number;
}
export interface ExecRequest {
type: "exec";
requestId: string;
execId: string;
script: string;
stdin?: string;
cwd?: string;
env?: Record<string, string>;
replaceEnv?: boolean;
timeoutMs: number;
maxStdoutBytes: number;
maxStderrBytes: number;
}
export interface AbortRequest {
type: "abort";
requestId: string;
}
export interface FilesWriteRequest {
type: "files_write";
requestId: string;
files: Array<{
path: string;
content: string;
encoding: "utf8" | "base64";
}>;
overwrite: boolean;
createDirs: boolean;
}
export interface FilesReadRequest {
type: "files_read";
requestId: string;
path: string;
offset: number;
maxBytes: number;
encoding: "utf8" | "base64" | "auto";
}
export interface FilesListRequest {
type: "files_list";
requestId: string;
path: string;
recursive: boolean;
glob?: string;
maxEntries: number;
cursor?: string;
}
export interface FsBytesRequest {
type: "fs_bytes";
requestId: string;
}
export type ParentMessage =
| InitMessage
| ExecRequest
| AbortRequest
| FilesWriteRequest
| FilesReadRequest
| FilesListRequest
| FsBytesRequest;
export interface ReadyMessage {
type: "ready";
}
export interface ExecResult {
type: "exec_result";
requestId: string;
execId: string;
exitCode: number;
stdout: string;
stderr: string;
durationMs: number;
timedOut: boolean;
truncatedStdout: boolean;
truncatedStderr: boolean;
// Total captured byte counts for resource link bookkeeping (>= embedded length).
capturedStdoutBytes: number;
capturedStderrBytes: number;
// Optional retained full bytes when above the embed cap (capped by maxCapturedOutputBytesExec).
retainedStdout?: string;
retainedStderr?: string;
commands: string[];
sessionFsBytes: number;
}
export interface FilesWriteResult {
type: "files_write_result";
requestId: string;
written: Array<{ path: string; bytes: number }>;
sessionFsBytes: number;
}
export interface FilesReadResult {
type: "files_read_result";
requestId: string;
path: string;
content: string;
encoding: "utf8" | "base64";
bytesRead: number;
nextOffset: number | null;
}
export interface FilesListEntry {
path: string;
type: "file" | "directory" | "symlink";
bytes?: number;
}
export interface FilesListResult {
type: "files_list_result";
requestId: string;
entries: FilesListEntry[];
nextCursor: string | null;
}
export interface FsBytesResult {
type: "fs_bytes_result";
requestId: string;
sessionFsBytes: number;
}
export interface ErrorResult {
type: "error_result";
requestId: string;
code: string;
message: string;
}
export type WorkerMessage =
| ReadyMessage
| ExecResult
| FilesWriteResult
| FilesReadResult
| FilesListResult
| FsBytesResult
| ErrorResult;
|