@rivet-dev/agentos 0.0.0-main.29b0797 → 0.0.0-main.5ac5a14
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/assets/inspector-tabs-app/assets/__vite-browser-external-2447137e-BIHI7g3E.js +1 -0
- package/assets/inspector-tabs-app/assets/agentos-hero-logo-E3fapwXM.svg +74 -0
- package/assets/inspector-tabs-app/assets/filesystem-C-x0K5sy.js +1 -0
- package/assets/inspector-tabs-app/assets/hooks-DU8a-cwM.js +1 -0
- package/assets/inspector-tabs-app/assets/index-7G_DbdZ6.js +110 -0
- package/assets/inspector-tabs-app/assets/index-DG_s1YoH.css +1 -0
- package/assets/inspector-tabs-app/assets/scroll-area-kPbv4IGy.js +1 -0
- package/assets/inspector-tabs-app/assets/sed-BwsOyU9v.svg +1 -0
- package/assets/inspector-tabs-app/assets/system-D98yBhMj.js +2 -0
- package/assets/inspector-tabs-app/assets/terminal-Bv9GKv4q.js +13 -0
- package/assets/inspector-tabs-app/assets/transcript-kMbm_tF8.js +1 -0
- package/assets/inspector-tabs-app/assets/useSuspenseQuery-ChN8rnBd.js +1 -0
- package/assets/inspector-tabs-app/assets/vm-boot-gate-rpuO0b5W.js +1 -0
- package/assets/inspector-tabs-app/assets/vm-status-badges-09qyfN_A.js +5 -0
- package/assets/inspector-tabs-app/index.html +2 -2
- package/dist/chunk-V6TY7KAL.js +8 -0
- package/dist/chunk-V6TY7KAL.js.map +1 -0
- package/dist/index.d.ts +328 -22
- package/dist/index.js +1238 -138
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +67 -0
- package/dist/node.js +275 -0
- package/dist/node.js.map +1 -0
- package/package.json +22 -10
- package/assets/inspector-tabs-app/assets/badge-NKTqivIc.js +0 -1
- package/assets/inspector-tabs-app/assets/filesystem-CyIvO-1j.js +0 -1
- package/assets/inspector-tabs-app/assets/index-DcBRn-yP.js +0 -125
- package/assets/inspector-tabs-app/assets/index-Dt5XhJ9h.css +0 -1
- package/assets/inspector-tabs-app/assets/mounts-DWpTN-N6.js +0 -1
- package/assets/inspector-tabs-app/assets/processes-CUocx7Ya.js +0 -1
- package/assets/inspector-tabs-app/assets/scroll-area-C07uoUZ4.js +0 -1
- package/assets/inspector-tabs-app/assets/software-ftDfKuwh.js +0 -1
- package/assets/inspector-tabs-app/assets/transcript-7Ao7EjSb.js +0 -1
- package/assets/inspector-tabs-app/assets/useSuspenseQuery-DBzwnHO3.js +0 -1
package/dist/node.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__publicField
|
|
3
|
+
} from "./chunk-V6TY7KAL.js";
|
|
4
|
+
|
|
5
|
+
// src/node.ts
|
|
6
|
+
import { Buffer } from "buffer";
|
|
7
|
+
var DEFAULT_MAX_PENDING_OUTPUT_BYTES = 8 * 1024 * 1024;
|
|
8
|
+
var OUTPUT_LIMIT_WARNING_RATIO = 0.8;
|
|
9
|
+
var TRAILING_OUTPUT_GRACE_MS = 250;
|
|
10
|
+
var NodeShellOutputLimitError = class extends Error {
|
|
11
|
+
constructor(limitBytes, pendingBytes) {
|
|
12
|
+
super(
|
|
13
|
+
`AgentOS Node shell pending output exceeded ${limitBytes} bytes (${pendingBytes} bytes pending); raise AttachShellOptions.maxPendingOutputBytes to allow more`
|
|
14
|
+
);
|
|
15
|
+
this.limitBytes = limitBytes;
|
|
16
|
+
this.pendingBytes = pendingBytes;
|
|
17
|
+
__publicField(this, "code", "AGENTOS_NODE_SHELL_OUTPUT_LIMIT");
|
|
18
|
+
this.name = "NodeShellOutputLimitError";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var NodeShellCleanupError = class extends Error {
|
|
22
|
+
constructor(errors) {
|
|
23
|
+
super("AgentOS Node shell and cleanup both failed");
|
|
24
|
+
this.errors = errors;
|
|
25
|
+
__publicField(this, "code", "AGENTOS_NODE_SHELL_CLEANUP_FAILED");
|
|
26
|
+
this.name = "NodeShellCleanupError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
async function attachShell(connection, options = {}) {
|
|
30
|
+
const stdin = options.stdin ?? process.stdin;
|
|
31
|
+
const stdout = options.stdout ?? process.stdout;
|
|
32
|
+
const stderr = options.stderr ?? process.stderr;
|
|
33
|
+
const events = connection;
|
|
34
|
+
if (typeof events.on !== "function") {
|
|
35
|
+
throw new TypeError("attachShell requires an AgentOS connection with on()");
|
|
36
|
+
}
|
|
37
|
+
const maxPendingOutputBytes = options.maxPendingOutputBytes ?? DEFAULT_MAX_PENDING_OUTPUT_BYTES;
|
|
38
|
+
if (!Number.isSafeInteger(maxPendingOutputBytes) || maxPendingOutputBytes <= 0) {
|
|
39
|
+
throw new RangeError(
|
|
40
|
+
"AttachShellOptions.maxPendingOutputBytes must be a positive safe integer"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const warn = options.onWarning ?? ((message) => stderr.write(`${message}
|
|
44
|
+
`));
|
|
45
|
+
let shellId;
|
|
46
|
+
let shellClosed = false;
|
|
47
|
+
let failure;
|
|
48
|
+
let resolveFailure;
|
|
49
|
+
const failurePromise = new Promise((resolve) => {
|
|
50
|
+
resolveFailure = resolve;
|
|
51
|
+
});
|
|
52
|
+
const fail = (error) => {
|
|
53
|
+
if (failure) return;
|
|
54
|
+
failure = error;
|
|
55
|
+
resolveFailure?.({ kind: "failure", error });
|
|
56
|
+
};
|
|
57
|
+
const earlyOutput = [];
|
|
58
|
+
let earlyOutputBytes = 0;
|
|
59
|
+
let earlyOutputWarned = false;
|
|
60
|
+
let resolveShellExit;
|
|
61
|
+
const shellExitPromise = new Promise((resolve) => {
|
|
62
|
+
resolveShellExit = resolve;
|
|
63
|
+
});
|
|
64
|
+
const onShellData = (payload) => {
|
|
65
|
+
routeOutput("stdout", payload);
|
|
66
|
+
};
|
|
67
|
+
const onShellStderr = (payload) => {
|
|
68
|
+
routeOutput("stderr", payload);
|
|
69
|
+
};
|
|
70
|
+
const onShellExit = (payload) => {
|
|
71
|
+
if (shellId && payload.shellId === shellId) resolveShellExit?.();
|
|
72
|
+
};
|
|
73
|
+
const unsubscribers = [
|
|
74
|
+
subscribe(events, "shellData", onShellData),
|
|
75
|
+
subscribe(events, "shellStderr", onShellStderr),
|
|
76
|
+
subscribe(events, "shellExit", onShellExit)
|
|
77
|
+
];
|
|
78
|
+
function routeOutput(stream, payload) {
|
|
79
|
+
try {
|
|
80
|
+
const bytes = toBytes(payload.data);
|
|
81
|
+
if (bytes.byteLength === 0) return;
|
|
82
|
+
if (!shellId) {
|
|
83
|
+
const nextBytes = earlyOutputBytes + bytes.byteLength;
|
|
84
|
+
if (nextBytes > maxPendingOutputBytes) {
|
|
85
|
+
fail(new NodeShellOutputLimitError(maxPendingOutputBytes, nextBytes));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
earlyOutputBytes = nextBytes;
|
|
89
|
+
earlyOutput.push({ stream, payload, bytes });
|
|
90
|
+
if (!earlyOutputWarned && nextBytes >= Math.floor(maxPendingOutputBytes * OUTPUT_LIMIT_WARNING_RATIO)) {
|
|
91
|
+
earlyOutputWarned = true;
|
|
92
|
+
warn(
|
|
93
|
+
`AgentOS Node shell pending output is near its ${maxPendingOutputBytes}-byte limit (${nextBytes} bytes pending)`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (payload.shellId !== shellId) return;
|
|
99
|
+
(stream === "stdout" ? stdout : stderr).write(bytes);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
fail(asError(error));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
let inputAttached = false;
|
|
105
|
+
let rawModeChanged = false;
|
|
106
|
+
let previousRawMode = false;
|
|
107
|
+
let inputWrite = Promise.resolve();
|
|
108
|
+
let inputEnded = false;
|
|
109
|
+
let resizeAttached = false;
|
|
110
|
+
let signalOutcomeResolve;
|
|
111
|
+
const signalPromise = new Promise((resolve) => {
|
|
112
|
+
signalOutcomeResolve = resolve;
|
|
113
|
+
});
|
|
114
|
+
const signalHandlers = /* @__PURE__ */ new Map();
|
|
115
|
+
const onInputData = (data) => {
|
|
116
|
+
stdin.pause();
|
|
117
|
+
inputWrite = inputWrite.then(async () => {
|
|
118
|
+
if (shellId) await connection.writeShell(shellId, data);
|
|
119
|
+
}).then(() => {
|
|
120
|
+
if (!inputEnded) stdin.resume();
|
|
121
|
+
}).catch((error) => fail(asError(error)));
|
|
122
|
+
};
|
|
123
|
+
const onInputEnd = () => {
|
|
124
|
+
inputEnded = true;
|
|
125
|
+
stdin.pause();
|
|
126
|
+
inputWrite = inputWrite.then(async () => {
|
|
127
|
+
if (shellId) await connection.writeShell(shellId, "");
|
|
128
|
+
}).catch((error) => fail(asError(error)));
|
|
129
|
+
};
|
|
130
|
+
const onInputError = (error) => fail(error);
|
|
131
|
+
const onResize = () => {
|
|
132
|
+
if (!shellId) return;
|
|
133
|
+
const cols = stdout.columns;
|
|
134
|
+
const rows = stdout.rows;
|
|
135
|
+
if (!positiveInteger(cols) || !positiveInteger(rows)) return;
|
|
136
|
+
void connection.resizeShell(shellId, cols, rows).catch((error) => {
|
|
137
|
+
fail(asError(error));
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
try {
|
|
141
|
+
const opened = await connection.openShell({
|
|
142
|
+
command: options.command,
|
|
143
|
+
args: options.args,
|
|
144
|
+
env: options.env,
|
|
145
|
+
cwd: options.cwd,
|
|
146
|
+
cols: options.cols ?? stdout.columns,
|
|
147
|
+
rows: options.rows ?? stdout.rows
|
|
148
|
+
});
|
|
149
|
+
shellId = opened.shellId;
|
|
150
|
+
for (const item of earlyOutput) {
|
|
151
|
+
if (item.payload.shellId !== shellId) continue;
|
|
152
|
+
(item.stream === "stdout" ? stdout : stderr).write(item.bytes);
|
|
153
|
+
}
|
|
154
|
+
earlyOutput.length = 0;
|
|
155
|
+
earlyOutputBytes = 0;
|
|
156
|
+
if (failure) throw failure;
|
|
157
|
+
previousRawMode = Boolean(stdin.isRaw);
|
|
158
|
+
if ((options.rawMode ?? true) && stdin.isTTY && typeof stdin.setRawMode === "function" && !previousRawMode) {
|
|
159
|
+
stdin.setRawMode(true);
|
|
160
|
+
rawModeChanged = true;
|
|
161
|
+
}
|
|
162
|
+
stdin.on("data", onInputData);
|
|
163
|
+
stdin.on("end", onInputEnd);
|
|
164
|
+
stdin.on("error", onInputError);
|
|
165
|
+
stdin.resume();
|
|
166
|
+
inputAttached = true;
|
|
167
|
+
if ((options.resize ?? true) && stdout.isTTY) {
|
|
168
|
+
stdout.on("resize", onResize);
|
|
169
|
+
resizeAttached = true;
|
|
170
|
+
onResize();
|
|
171
|
+
}
|
|
172
|
+
for (const signal of options.signals ?? ["SIGINT", "SIGHUP", "SIGTERM"]) {
|
|
173
|
+
const handler = () => {
|
|
174
|
+
signalOutcomeResolve?.({
|
|
175
|
+
kind: "signal",
|
|
176
|
+
signal,
|
|
177
|
+
exitCode: signalExitCode(signal)
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
signalHandlers.set(signal, handler);
|
|
181
|
+
process.once(signal, handler);
|
|
182
|
+
}
|
|
183
|
+
const outcome = await Promise.race([
|
|
184
|
+
connection.waitShell(shellId).then((exitCode) => ({
|
|
185
|
+
kind: "exit",
|
|
186
|
+
exitCode
|
|
187
|
+
})),
|
|
188
|
+
failurePromise,
|
|
189
|
+
signalPromise
|
|
190
|
+
]);
|
|
191
|
+
if (outcome.kind === "failure") {
|
|
192
|
+
await connection.closeShell(shellId);
|
|
193
|
+
shellClosed = true;
|
|
194
|
+
throw outcome.error;
|
|
195
|
+
}
|
|
196
|
+
if (outcome.kind === "signal") {
|
|
197
|
+
await connection.closeShell(shellId);
|
|
198
|
+
shellClosed = true;
|
|
199
|
+
return outcome.exitCode;
|
|
200
|
+
}
|
|
201
|
+
await Promise.race([
|
|
202
|
+
shellExitPromise,
|
|
203
|
+
new Promise(
|
|
204
|
+
(resolve) => setTimeout(resolve, TRAILING_OUTPUT_GRACE_MS)
|
|
205
|
+
)
|
|
206
|
+
]);
|
|
207
|
+
await inputWrite;
|
|
208
|
+
if (failure) throw failure;
|
|
209
|
+
return outcome.exitCode;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
if (shellId && !shellClosed) {
|
|
212
|
+
try {
|
|
213
|
+
await connection.closeShell(shellId);
|
|
214
|
+
shellClosed = true;
|
|
215
|
+
} catch (closeError) {
|
|
216
|
+
throw new NodeShellCleanupError([asError(error), asError(closeError)]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
throw error;
|
|
220
|
+
} finally {
|
|
221
|
+
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
222
|
+
if (inputAttached) {
|
|
223
|
+
stdin.removeListener("data", onInputData);
|
|
224
|
+
stdin.removeListener("end", onInputEnd);
|
|
225
|
+
stdin.removeListener("error", onInputError);
|
|
226
|
+
stdin.pause();
|
|
227
|
+
}
|
|
228
|
+
if (resizeAttached) stdout.removeListener("resize", onResize);
|
|
229
|
+
if (rawModeChanged) stdin.setRawMode?.(previousRawMode);
|
|
230
|
+
for (const [signal, handler] of signalHandlers) {
|
|
231
|
+
process.removeListener(signal, handler);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function subscribe(events, event, listener) {
|
|
236
|
+
const untypedListener = listener;
|
|
237
|
+
const result = events.on(event, untypedListener);
|
|
238
|
+
if (typeof result === "function") return result;
|
|
239
|
+
return () => {
|
|
240
|
+
if (events.off) events.off(event, untypedListener);
|
|
241
|
+
else events.removeListener?.(event, untypedListener);
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function toBytes(data) {
|
|
245
|
+
if (data instanceof Uint8Array) return data;
|
|
246
|
+
if (Array.isArray(data) && data.length === 2 && data[0] === "$Uint8Array" && typeof data[1] === "string") {
|
|
247
|
+
return Buffer.from(data[1], "base64");
|
|
248
|
+
}
|
|
249
|
+
if (typeof data === "string") return Buffer.from(data, "utf8");
|
|
250
|
+
throw new TypeError(
|
|
251
|
+
`Unsupported AgentOS shell data payload: ${String(data)}`
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
function positiveInteger(value) {
|
|
255
|
+
return Number.isInteger(value) && (value ?? 0) > 0;
|
|
256
|
+
}
|
|
257
|
+
function signalExitCode(signal) {
|
|
258
|
+
switch (signal) {
|
|
259
|
+
case "SIGHUP":
|
|
260
|
+
return 129;
|
|
261
|
+
case "SIGINT":
|
|
262
|
+
return 130;
|
|
263
|
+
case "SIGTERM":
|
|
264
|
+
return 143;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function asError(error) {
|
|
268
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
269
|
+
}
|
|
270
|
+
export {
|
|
271
|
+
NodeShellCleanupError,
|
|
272
|
+
NodeShellOutputLimitError,
|
|
273
|
+
attachShell
|
|
274
|
+
};
|
|
275
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node.ts"],"sourcesContent":["import { Buffer } from \"node:buffer\";\n\nconst DEFAULT_MAX_PENDING_OUTPUT_BYTES = 8 * 1024 * 1024;\nconst OUTPUT_LIMIT_WARNING_RATIO = 0.8;\nconst TRAILING_OUTPUT_GRACE_MS = 250;\n\nexport interface NodeShellOpenOptions {\n\tcommand?: string;\n\targs?: string[];\n\tenv?: Record<string, string>;\n\tcwd?: string;\n\tcols?: number;\n\trows?: number;\n}\n\nexport interface NodeShellConnection {\n\topenShell(options?: NodeShellOpenOptions): Promise<{ shellId: string }>;\n\twriteShell(shellId: string, data: string | Uint8Array): Promise<void>;\n\tresizeShell(shellId: string, cols: number, rows: number): Promise<void>;\n\tcloseShell(shellId: string): Promise<void>;\n\twaitShell(shellId: string): Promise<number>;\n}\n\nexport interface NodeShellInput {\n\tisTTY?: boolean;\n\tisRaw?: boolean;\n\tsetRawMode?(enabled: boolean): unknown;\n\ton(event: \"data\", listener: (data: string | Uint8Array) => void): unknown;\n\ton(event: \"end\", listener: () => void): unknown;\n\ton(event: \"error\", listener: (error: Error) => void): unknown;\n\tremoveListener(\n\t\tevent: \"data\",\n\t\tlistener: (data: string | Uint8Array) => void,\n\t): unknown;\n\tremoveListener(event: \"end\", listener: () => void): unknown;\n\tremoveListener(event: \"error\", listener: (error: Error) => void): unknown;\n\tpause(): unknown;\n\tresume(): unknown;\n}\n\nexport interface NodeShellOutput {\n\tisTTY?: boolean;\n\tcolumns?: number;\n\trows?: number;\n\twrite(data: string | Uint8Array): boolean;\n\ton(event: \"resize\", listener: () => void): unknown;\n\tremoveListener(event: \"resize\", listener: () => void): unknown;\n}\n\nexport type NodeShellSignal = \"SIGINT\" | \"SIGHUP\" | \"SIGTERM\";\n\nexport interface AttachShellOptions extends NodeShellOpenOptions {\n\tstdin?: NodeShellInput;\n\tstdout?: NodeShellOutput;\n\tstderr?: NodeShellOutput;\n\trawMode?: boolean;\n\tresize?: boolean;\n\tsignals?: readonly NodeShellSignal[];\n\tmaxPendingOutputBytes?: number;\n\tonWarning?: (message: string) => void;\n}\n\ninterface ShellDataPayload {\n\tshellId: string;\n\tdata: unknown;\n}\n\ninterface ShellExitPayload {\n\tshellId: string;\n\texitCode: number;\n}\n\ninterface ShellEventSource {\n\ton(event: string, listener: (payload: never) => void): unknown;\n\toff?(event: string, listener: (payload: never) => void): unknown;\n\tremoveListener?(event: string, listener: (payload: never) => void): unknown;\n}\n\ntype EarlyOutput = {\n\tstream: \"stdout\" | \"stderr\";\n\tpayload: ShellDataPayload;\n\tbytes: Uint8Array;\n};\n\ntype AttachOutcome =\n\t| { kind: \"exit\"; exitCode: number }\n\t| { kind: \"failure\"; error: Error }\n\t| { kind: \"signal\"; signal: NodeShellSignal; exitCode: number };\n\nexport class NodeShellOutputLimitError extends Error {\n\treadonly code = \"AGENTOS_NODE_SHELL_OUTPUT_LIMIT\";\n\n\tconstructor(\n\t\treadonly limitBytes: number,\n\t\treadonly pendingBytes: number,\n\t) {\n\t\tsuper(\n\t\t\t`AgentOS Node shell pending output exceeded ${limitBytes} bytes ` +\n\t\t\t\t`(${pendingBytes} bytes pending); raise AttachShellOptions.maxPendingOutputBytes to allow more`,\n\t\t);\n\t\tthis.name = \"NodeShellOutputLimitError\";\n\t}\n}\n\nexport class NodeShellCleanupError extends Error {\n\treadonly code = \"AGENTOS_NODE_SHELL_CLEANUP_FAILED\";\n\n\tconstructor(readonly errors: readonly Error[]) {\n\t\tsuper(\"AgentOS Node shell and cleanup both failed\");\n\t\tthis.name = \"NodeShellCleanupError\";\n\t}\n}\n\n/**\n * Open an AgentOS PTY shell and attach it to the current Node process terminal.\n * The connection must expose AgentOS shell actions and its broadcast `on()` API.\n */\nexport async function attachShell(\n\tconnection: NodeShellConnection,\n\toptions: AttachShellOptions = {},\n): Promise<number> {\n\tconst stdin = options.stdin ?? process.stdin;\n\tconst stdout = options.stdout ?? process.stdout;\n\tconst stderr = options.stderr ?? process.stderr;\n\tconst events = connection as unknown as ShellEventSource;\n\tif (typeof events.on !== \"function\") {\n\t\tthrow new TypeError(\"attachShell requires an AgentOS connection with on()\");\n\t}\n\n\tconst maxPendingOutputBytes =\n\t\toptions.maxPendingOutputBytes ?? DEFAULT_MAX_PENDING_OUTPUT_BYTES;\n\tif (\n\t\t!Number.isSafeInteger(maxPendingOutputBytes) ||\n\t\tmaxPendingOutputBytes <= 0\n\t) {\n\t\tthrow new RangeError(\n\t\t\t\"AttachShellOptions.maxPendingOutputBytes must be a positive safe integer\",\n\t\t);\n\t}\n\n\tconst warn =\n\t\toptions.onWarning ?? ((message: string) => stderr.write(`${message}\\n`));\n\tlet shellId: string | undefined;\n\tlet shellClosed = false;\n\tlet failure: Error | undefined;\n\tlet resolveFailure: ((outcome: AttachOutcome) => void) | undefined;\n\tconst failurePromise = new Promise<AttachOutcome>((resolve) => {\n\t\tresolveFailure = resolve;\n\t});\n\tconst fail = (error: Error) => {\n\t\tif (failure) return;\n\t\tfailure = error;\n\t\tresolveFailure?.({ kind: \"failure\", error });\n\t};\n\tconst earlyOutput: EarlyOutput[] = [];\n\tlet earlyOutputBytes = 0;\n\tlet earlyOutputWarned = false;\n\tlet resolveShellExit: (() => void) | undefined;\n\tconst shellExitPromise = new Promise<void>((resolve) => {\n\t\tresolveShellExit = resolve;\n\t});\n\n\tconst onShellData = (payload: ShellDataPayload) => {\n\t\trouteOutput(\"stdout\", payload);\n\t};\n\tconst onShellStderr = (payload: ShellDataPayload) => {\n\t\trouteOutput(\"stderr\", payload);\n\t};\n\tconst onShellExit = (payload: ShellExitPayload) => {\n\t\tif (shellId && payload.shellId === shellId) resolveShellExit?.();\n\t};\n\tconst unsubscribers = [\n\t\tsubscribe(events, \"shellData\", onShellData),\n\t\tsubscribe(events, \"shellStderr\", onShellStderr),\n\t\tsubscribe(events, \"shellExit\", onShellExit),\n\t];\n\n\tfunction routeOutput(\n\t\tstream: \"stdout\" | \"stderr\",\n\t\tpayload: ShellDataPayload,\n\t): void {\n\t\ttry {\n\t\t\tconst bytes = toBytes(payload.data);\n\t\t\tif (bytes.byteLength === 0) return;\n\t\t\tif (!shellId) {\n\t\t\t\tconst nextBytes = earlyOutputBytes + bytes.byteLength;\n\t\t\t\tif (nextBytes > maxPendingOutputBytes) {\n\t\t\t\t\tfail(new NodeShellOutputLimitError(maxPendingOutputBytes, nextBytes));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tearlyOutputBytes = nextBytes;\n\t\t\t\tearlyOutput.push({ stream, payload, bytes });\n\t\t\t\tif (\n\t\t\t\t\t!earlyOutputWarned &&\n\t\t\t\t\tnextBytes >=\n\t\t\t\t\t\tMath.floor(maxPendingOutputBytes * OUTPUT_LIMIT_WARNING_RATIO)\n\t\t\t\t) {\n\t\t\t\t\tearlyOutputWarned = true;\n\t\t\t\t\twarn(\n\t\t\t\t\t\t`AgentOS Node shell pending output is near its ${maxPendingOutputBytes}-byte limit ` +\n\t\t\t\t\t\t\t`(${nextBytes} bytes pending)`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (payload.shellId !== shellId) return;\n\t\t\t(stream === \"stdout\" ? stdout : stderr).write(bytes);\n\t\t} catch (error) {\n\t\t\tfail(asError(error));\n\t\t}\n\t}\n\n\tlet inputAttached = false;\n\tlet rawModeChanged = false;\n\tlet previousRawMode = false;\n\tlet inputWrite = Promise.resolve();\n\tlet inputEnded = false;\n\tlet resizeAttached = false;\n\tlet signalOutcomeResolve: ((outcome: AttachOutcome) => void) | undefined;\n\tconst signalPromise = new Promise<AttachOutcome>((resolve) => {\n\t\tsignalOutcomeResolve = resolve;\n\t});\n\tconst signalHandlers = new Map<NodeShellSignal, () => void>();\n\n\tconst onInputData = (data: string | Uint8Array) => {\n\t\tstdin.pause();\n\t\tinputWrite = inputWrite\n\t\t\t.then(async () => {\n\t\t\t\tif (shellId) await connection.writeShell(shellId, data);\n\t\t\t})\n\t\t\t.then(() => {\n\t\t\t\tif (!inputEnded) stdin.resume();\n\t\t\t})\n\t\t\t.catch((error) => fail(asError(error)));\n\t};\n\tconst onInputEnd = () => {\n\t\tinputEnded = true;\n\t\tstdin.pause();\n\t\tinputWrite = inputWrite\n\t\t\t.then(async () => {\n\t\t\t\tif (shellId) await connection.writeShell(shellId, \"\\u0004\");\n\t\t\t})\n\t\t\t.catch((error) => fail(asError(error)));\n\t};\n\tconst onInputError = (error: Error) => fail(error);\n\tconst onResize = () => {\n\t\tif (!shellId) return;\n\t\tconst cols = stdout.columns;\n\t\tconst rows = stdout.rows;\n\t\tif (!positiveInteger(cols) || !positiveInteger(rows)) return;\n\t\tvoid connection.resizeShell(shellId, cols, rows).catch((error) => {\n\t\t\tfail(asError(error));\n\t\t});\n\t};\n\n\ttry {\n\t\tconst opened = await connection.openShell({\n\t\t\tcommand: options.command,\n\t\t\targs: options.args,\n\t\t\tenv: options.env,\n\t\t\tcwd: options.cwd,\n\t\t\tcols: options.cols ?? stdout.columns,\n\t\t\trows: options.rows ?? stdout.rows,\n\t\t});\n\t\tshellId = opened.shellId;\n\t\tfor (const item of earlyOutput) {\n\t\t\tif (item.payload.shellId !== shellId) continue;\n\t\t\t(item.stream === \"stdout\" ? stdout : stderr).write(item.bytes);\n\t\t}\n\t\tearlyOutput.length = 0;\n\t\tearlyOutputBytes = 0;\n\t\tif (failure) throw failure;\n\n\t\tpreviousRawMode = Boolean(stdin.isRaw);\n\t\tif (\n\t\t\t(options.rawMode ?? true) &&\n\t\t\tstdin.isTTY &&\n\t\t\ttypeof stdin.setRawMode === \"function\" &&\n\t\t\t!previousRawMode\n\t\t) {\n\t\t\tstdin.setRawMode(true);\n\t\t\trawModeChanged = true;\n\t\t}\n\t\tstdin.on(\"data\", onInputData);\n\t\tstdin.on(\"end\", onInputEnd);\n\t\tstdin.on(\"error\", onInputError);\n\t\tstdin.resume();\n\t\tinputAttached = true;\n\n\t\tif ((options.resize ?? true) && stdout.isTTY) {\n\t\t\tstdout.on(\"resize\", onResize);\n\t\t\tresizeAttached = true;\n\t\t\tonResize();\n\t\t}\n\n\t\tfor (const signal of options.signals ?? [\"SIGINT\", \"SIGHUP\", \"SIGTERM\"]) {\n\t\t\tconst handler = () => {\n\t\t\t\tsignalOutcomeResolve?.({\n\t\t\t\t\tkind: \"signal\",\n\t\t\t\t\tsignal,\n\t\t\t\t\texitCode: signalExitCode(signal),\n\t\t\t\t});\n\t\t\t};\n\t\t\tsignalHandlers.set(signal, handler);\n\t\t\tprocess.once(signal, handler);\n\t\t}\n\n\t\tconst outcome = await Promise.race<AttachOutcome>([\n\t\t\tconnection.waitShell(shellId).then((exitCode) => ({\n\t\t\t\tkind: \"exit\" as const,\n\t\t\t\texitCode,\n\t\t\t})),\n\t\t\tfailurePromise,\n\t\t\tsignalPromise,\n\t\t]);\n\t\tif (outcome.kind === \"failure\") {\n\t\t\tawait connection.closeShell(shellId);\n\t\t\tshellClosed = true;\n\t\t\tthrow outcome.error;\n\t\t}\n\t\tif (outcome.kind === \"signal\") {\n\t\t\tawait connection.closeShell(shellId);\n\t\t\tshellClosed = true;\n\t\t\treturn outcome.exitCode;\n\t\t}\n\n\t\tawait Promise.race([\n\t\t\tshellExitPromise,\n\t\t\tnew Promise<void>((resolve) =>\n\t\t\t\tsetTimeout(resolve, TRAILING_OUTPUT_GRACE_MS),\n\t\t\t),\n\t\t]);\n\t\tawait inputWrite;\n\t\tif (failure) throw failure;\n\t\treturn outcome.exitCode;\n\t} catch (error) {\n\t\tif (shellId && !shellClosed) {\n\t\t\ttry {\n\t\t\t\tawait connection.closeShell(shellId);\n\t\t\t\tshellClosed = true;\n\t\t\t} catch (closeError) {\n\t\t\t\tthrow new NodeShellCleanupError([asError(error), asError(closeError)]);\n\t\t\t}\n\t\t}\n\t\tthrow error;\n\t} finally {\n\t\tfor (const unsubscribe of unsubscribers) unsubscribe();\n\t\tif (inputAttached) {\n\t\t\tstdin.removeListener(\"data\", onInputData);\n\t\t\tstdin.removeListener(\"end\", onInputEnd);\n\t\t\tstdin.removeListener(\"error\", onInputError);\n\t\t\tstdin.pause();\n\t\t}\n\t\tif (resizeAttached) stdout.removeListener(\"resize\", onResize);\n\t\tif (rawModeChanged) stdin.setRawMode?.(previousRawMode);\n\t\tfor (const [signal, handler] of signalHandlers) {\n\t\t\tprocess.removeListener(signal, handler);\n\t\t}\n\t}\n}\n\nfunction subscribe<TPayload>(\n\tevents: ShellEventSource,\n\tevent: string,\n\tlistener: (payload: TPayload) => void,\n): () => void {\n\tconst untypedListener = listener as (payload: never) => void;\n\tconst result = events.on(event, untypedListener);\n\tif (typeof result === \"function\") return result as () => void;\n\treturn () => {\n\t\tif (events.off) events.off(event, untypedListener);\n\t\telse events.removeListener?.(event, untypedListener);\n\t};\n}\n\nfunction toBytes(data: unknown): Uint8Array {\n\tif (data instanceof Uint8Array) return data;\n\tif (\n\t\tArray.isArray(data) &&\n\t\tdata.length === 2 &&\n\t\tdata[0] === \"$Uint8Array\" &&\n\t\ttypeof data[1] === \"string\"\n\t) {\n\t\treturn Buffer.from(data[1], \"base64\");\n\t}\n\tif (typeof data === \"string\") return Buffer.from(data, \"utf8\");\n\tthrow new TypeError(\n\t\t`Unsupported AgentOS shell data payload: ${String(data)}`,\n\t);\n}\n\nfunction positiveInteger(value: number | undefined): value is number {\n\treturn Number.isInteger(value) && (value ?? 0) > 0;\n}\n\nfunction signalExitCode(signal: NodeShellSignal): number {\n\tswitch (signal) {\n\t\tcase \"SIGHUP\":\n\t\t\treturn 129;\n\t\tcase \"SIGINT\":\n\t\t\treturn 130;\n\t\tcase \"SIGTERM\":\n\t\t\treturn 143;\n\t}\n}\n\nfunction asError(error: unknown): Error {\n\treturn error instanceof Error ? error : new Error(String(error));\n}\n"],"mappings":";;;;;AAAA,SAAS,cAAc;AAEvB,IAAM,mCAAmC,IAAI,OAAO;AACpD,IAAM,6BAA6B;AACnC,IAAM,2BAA2B;AAqF1B,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAGpD,YACU,YACA,cACR;AACD;AAAA,MACC,8CAA8C,UAAU,WACnD,YAAY;AAAA,IAClB;AANS;AACA;AAJV,wBAAS,QAAO;AAUf,SAAK,OAAO;AAAA,EACb;AACD;AAEO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAGhD,YAAqB,QAA0B;AAC9C,UAAM,4CAA4C;AAD9B;AAFrB,wBAAS,QAAO;AAIf,SAAK,OAAO;AAAA,EACb;AACD;AAMA,eAAsB,YACrB,YACA,UAA8B,CAAC,GACb;AAClB,QAAM,QAAQ,QAAQ,SAAS,QAAQ;AACvC,QAAM,SAAS,QAAQ,UAAU,QAAQ;AACzC,QAAM,SAAS,QAAQ,UAAU,QAAQ;AACzC,QAAM,SAAS;AACf,MAAI,OAAO,OAAO,OAAO,YAAY;AACpC,UAAM,IAAI,UAAU,sDAAsD;AAAA,EAC3E;AAEA,QAAM,wBACL,QAAQ,yBAAyB;AAClC,MACC,CAAC,OAAO,cAAc,qBAAqB,KAC3C,yBAAyB,GACxB;AACD,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AA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AkB;AACxB,QAAM,SAAS,OAAO,GAAG,OAAO,eAAe;AAC/C,MAAI,OAAO,WAAW,WAAY,QAAO;AACzC,SAAO,MAAM;AACZ,QAAI,OAAO,IAAK,QAAO,IAAI,OAAO,eAAe;AAAA,QAC5C,QAAO,iBAAiB,OAAO,eAAe;AAAA,EACpD;AACD;AAEA,SAAS,QAAQ,MAA2B;AAC3C,MAAI,gBAAgB,WAAY,QAAO;AACvC,MACC,MAAM,QAAQ,IAAI,KAClB,KAAK,WAAW,KAChB,KAAK,CAAC,MAAM,iBACZ,OAAO,KAAK,CAAC,MAAM,UAClB;AACD,WAAO,OAAO,KAAK,KAAK,CAAC,GAAG,QAAQ;AAAA,EACrC;AACA,MAAI,OAAO,SAAS,SAAU,QAAO,OAAO,KAAK,MAAM,MAAM;AAC7D,QAAM,IAAI;AAAA,IACT,2CAA2C,OAAO,IAAI,CAAC;AAAA,EACxD;AACD;AAEA,SAAS,gBAAgB,OAA4C;AACpE,SAAO,OAAO,UAAU,KAAK,MAAM,SAAS,KAAK;AAClD;AAEA,SAAS,eAAe,QAAiC;AACxD,UAAQ,QAAQ;AAAA,IACf,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,EACT;AACD;AAEA,SAAS,QAAQ,OAAuB;AACvC,SAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAChE;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivet-dev/agentos",
|
|
3
|
-
"version": "0.0.0-main.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.0-main.5ac5a14",
|
|
4
|
+
"description": "The AgentOS actor and orchestration SDK.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"rivetkit",
|
|
@@ -36,6 +36,12 @@
|
|
|
36
36
|
"default": "./dist/client.js"
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
+
"./node": {
|
|
40
|
+
"import": {
|
|
41
|
+
"types": "./dist/node.d.ts",
|
|
42
|
+
"default": "./dist/node.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
39
45
|
"./react": {
|
|
40
46
|
"import": {
|
|
41
47
|
"types": "./dist/react.d.ts",
|
|
@@ -48,21 +54,22 @@
|
|
|
48
54
|
},
|
|
49
55
|
"scripts": {
|
|
50
56
|
"build": "pnpm build:actor && pnpm build:tabs",
|
|
51
|
-
"build:actor": "tsup src/index.ts src/client.ts src/react.ts",
|
|
57
|
+
"build:actor": "tsup src/index.ts src/client.ts src/node.ts src/react.ts",
|
|
52
58
|
"build:tabs": "vite build --config vite.tabs.config.ts",
|
|
53
59
|
"check-types": "tsc --noEmit",
|
|
54
60
|
"test": "vitest run --exclude '**/*.nightly.test.ts'",
|
|
55
|
-
"test:pr": "AGENTOS_ACTOR_E2E=1 vitest run tests/agent-os-conformance.e2e.test.ts --fileParallelism=false",
|
|
61
|
+
"test:pr": "AGENTOS_ACTOR_E2E=1 vitest run tests/actor.test.ts tests/client.test.ts tests/agent-os-conformance.e2e.test.ts --fileParallelism=false",
|
|
56
62
|
"test:nightly": "AGENTOS_ACTOR_E2E=1 vitest run tests/*.nightly.test.ts tests/agent-os-conformance.e2e.test.ts --fileParallelism=false --passWithNoTests",
|
|
57
63
|
"test:e2e": "cargo build --manifest-path ../../Cargo.toml -p agentos-sidecar && pnpm --filter @rivet-dev/agentos-runtime-core build && pnpm --filter @agentos-software/manifest build && pnpm --filter @agentos-software/common... build && pnpm --filter @agentos-software/coreutils build:runtime && pnpm --filter @rivet-dev/agentos-test-harness build && pnpm --filter @rivet-dev/agentos-core build && pnpm build && pnpm test:e2e:run",
|
|
58
64
|
"test:e2e:run": "AGENTOS_ACTOR_E2E=1 vitest run tests/actor-lifecycle.nightly.test.ts tests/agent-os-conformance.e2e.test.ts --fileParallelism=false"
|
|
59
65
|
},
|
|
60
66
|
"dependencies": {
|
|
61
67
|
"@agentclientprotocol/sdk": "0.16.1",
|
|
62
|
-
"@agentos-software/common": "0.0.0-main.
|
|
63
|
-
"@rivet-dev/agentos-core": "0.0.0-main.
|
|
64
|
-
"@rivetkit/react": "
|
|
65
|
-
"
|
|
68
|
+
"@agentos-software/common": "0.0.0-main.5ac5a14",
|
|
69
|
+
"@rivet-dev/agentos-core": "0.0.0-main.5ac5a14",
|
|
70
|
+
"@rivetkit/react": "2.3.10",
|
|
71
|
+
"ghostty-web": "^0.4.0",
|
|
72
|
+
"rivetkit": "2.3.10",
|
|
66
73
|
"zod": "^4.1.11"
|
|
67
74
|
},
|
|
68
75
|
"peerDependencies": {
|
|
@@ -78,10 +85,10 @@
|
|
|
78
85
|
}
|
|
79
86
|
},
|
|
80
87
|
"devDependencies": {
|
|
81
|
-
"@agentos-software/coreutils": "0.3.
|
|
82
|
-
"@rivet-dev/agentos-test-harness": "0.0.0-main.29b0797",
|
|
88
|
+
"@agentos-software/coreutils": "0.3.4",
|
|
83
89
|
"@radix-ui/react-collapsible": "^1.1.2",
|
|
84
90
|
"@radix-ui/react-scroll-area": "^1.2.2",
|
|
91
|
+
"@rivet-dev/agentos-test-harness": "0.0.0-main.5ac5a14",
|
|
85
92
|
"@tanstack/react-query": "^5.87.1",
|
|
86
93
|
"@types/node": "^22.19.15",
|
|
87
94
|
"@types/react": "^19.0.0",
|
|
@@ -99,5 +106,10 @@
|
|
|
99
106
|
"typescript": "^5.7.3",
|
|
100
107
|
"vite": "^5.4.20",
|
|
101
108
|
"vitest": "^2.1.8"
|
|
109
|
+
},
|
|
110
|
+
"repository": {
|
|
111
|
+
"type": "git",
|
|
112
|
+
"url": "https://github.com/rivet-dev/agentos.git",
|
|
113
|
+
"directory": "packages/agentos"
|
|
102
114
|
}
|
|
103
115
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as N}from"./index-DcBRn-yP.js";import{k as j,f as k}from"./scroll-area-C07uoUZ4.js";const m=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,f=j,C=(e,a)=>n=>{var s;if((a==null?void 0:a.variants)==null)return f(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:u,defaultVariants:i}=a,y=Object.keys(u).map(t=>{const r=n==null?void 0:n[t],o=i==null?void 0:i[t];if(r===null)return null;const l=m(r)||m(o);return u[t][l]}),c=n&&Object.entries(n).reduce((t,r)=>{let[o,l]=r;return l===void 0||(t[o]=l),t},{}),x=a==null||(s=a.compoundVariants)===null||s===void 0?void 0:s.reduce((t,r)=>{let{class:o,className:l,...V}=r;return Object.entries(V).every(b=>{let[v,d]=b;return Array.isArray(d)?d.includes({...i,...c}[v]):{...i,...c}[v]===d})?[...t,o,l]:t},[]);return f(e,y,x,n==null?void 0:n.class,n==null?void 0:n.className)},g=C("inline-flex items-center tracking-normal rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors whitespace-nowrap max-w-full overflow-hidden truncate",{variants:{variant:{secondary:"border-transparent bg-secondary text-secondary-foreground",outline:"text-foreground"}},defaultVariants:{variant:"secondary"}});function h({className:e,variant:a,...n}){return N.jsx("div",{className:k(g({variant:a}),e),...n})}export{h as B};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as f,j as t}from"./index-DcBRn-yP.js";import{h as w,Q as C,e as j,S as N,A as c,C as S,f as p,F as k,i as g,r as Q}from"./scroll-area-C07uoUZ4.js";function v(n,e){return w(n,C)}function b({actorId:n,entry:e,depth:r,selectedPath:i,onSelect:o}){const[x,h]=f.useState(!1),d=e.path===i,a=e.dir&&!e.virtual,u=v(j.listDirQueryOptions(n,e.path,a&&x));return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1",style:{paddingLeft:`${r*12}px`},children:[t.jsx("button",{type:"button",onClick:()=>a&&h(s=>!s),className:p("flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-muted/50",!a&&"pointer-events-none opacity-0"),disabled:!a,children:t.jsx(S,{className:p("size-3 transition-transform",x&&"rotate-90")})}),t.jsxs("button",{type:"button",onClick:()=>a?h(s=>!s):e.dir?void 0:o(e),className:p("flex min-w-0 flex-1 items-center gap-2 rounded px-2 py-1 text-left text-sm",d?"bg-muted text-foreground":"hover:bg-muted/50"),children:[t.jsx(k,{dir:e.dir,className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"flex-1 truncate",children:e.name}),!e.dir&&e.size!=null?t.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/60",children:g(e.size)}):null]})]}),a&&x?u.isLoading?t.jsx("div",{className:"py-1 text-xs text-muted-foreground",style:{paddingLeft:`${(r+1)*12+28}px`},children:"loading…"}):(u.data??[]).map(s=>t.jsx(b,{actorId:n,entry:s,depth:r+1,selectedPath:i,onSelect:o},s.path)):null]})}function z({actorId:n,path:e}){const{data:r,error:i,isFetching:o}=v(j.fileContentQueryOptions(n,e));return e?i?t.jsxs(c,{children:["Failed to read ",e,": ",i.message]}):!r||o?t.jsxs(c,{children:["Loading ",e,"…"]}):t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[t.jsx("span",{className:"truncate font-mono text-sm",children:r.path}),t.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:g(r.sizeBytes)}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Q(r.mtimeMs)})]}),t.jsx(N,{className:"min-h-0 flex-1",children:r.text===null?t.jsxs("div",{className:"flex h-full items-center justify-center p-8 text-center text-sm text-muted-foreground",children:["Binary file (",g(r.sizeBytes),") — preview unavailable."]}):t.jsx("pre",{className:"whitespace-pre-wrap break-words p-4 font-mono text-xs leading-relaxed",children:r.text})})]}):t.jsx(c,{children:"Select a file to view its contents."})}function y(n){let e=n.trim();return e===""?"/":(e.startsWith("/")||(e=`/${e}`),e=e.replace(/\/+/g,"/"),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e)}function E({actorId:n}){const[e,r]=f.useState("/"),[i,o]=f.useState("/"),[x,h]=f.useState(null),d=v(j.listDirQueryOptions(n,e)),a=d.data===null,u=d.data??[];return f.useEffect(()=>{const s=setTimeout(()=>{const l=y(i);r(m=>l!==m?l:m)},500);return()=>clearTimeout(s)},[i]),t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsxs("div",{className:"flex h-full w-2/5 flex-col border-r",children:[t.jsx("div",{className:"border-b px-3 py-1.5",children:t.jsx("input",{value:i,onChange:s=>o(s.target.value),onKeyDown:s=>{if(s.key==="Enter"){const l=y(i);o(l),r(m=>l!==m?l:m)}},spellCheck:!1,autoComplete:"off","aria-label":"Root directory",placeholder:"/",className:"w-full bg-transparent font-mono text-xs text-muted-foreground outline-none placeholder:text-muted-foreground/40 focus:text-foreground"})}),t.jsx(N,{className:"min-h-0 flex-1 p-2",children:d.isLoading?t.jsxs(c,{children:["Loading ",e,"…"]}):d.error?t.jsxs(c,{children:["Failed to list ",e,": ",d.error.message]}):a?t.jsxs(c,{children:["Not a directory, or does not exist: ",e]}):u.length===0?t.jsx(c,{children:"Empty directory."}):u.map(s=>t.jsx(b,{actorId:n,entry:s,depth:0,selectedPath:x,onSelect:l=>h(l.path)},s.path))})]}),t.jsx("div",{className:"min-h-0 w-3/5",children:t.jsx(z,{actorId:n,path:x})})]})}export{E as FilesystemTabConnected};
|