@mastra/platform-workspace 1.9.0-alpha.1 → 1.10.0-alpha.0
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/_types/@internal_workspace/dist/commands-api-process-manager.d.ts +99 -0
- package/dist/_types/@internal_workspace/dist/index.d.ts +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/e2b-exec.d.ts +4 -0
- package/dist/e2b-exec.d.ts.map +1 -1
- package/dist/index.cjs +1004 -690
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +885 -571
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts +21 -16
- package/dist/sandbox.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ProcessHandle, SandboxProcessManager } from '@mastra/core/workspace';
|
|
2
|
+
import type { CommandResult, MastraSandbox, ProcessInfo, SpawnProcessOptions } from '@mastra/core/workspace';
|
|
3
|
+
/** A command as E2B's envd commands API reports it (`CommandHandle`), reduced to what is used here. */
|
|
4
|
+
export interface CommandsApiHandle {
|
|
5
|
+
readonly pid: number;
|
|
6
|
+
/** `undefined` while the command runs. */
|
|
7
|
+
readonly exitCode?: number;
|
|
8
|
+
/** Resolves on exit 0; rejects with a `CommandExitError`-shaped error otherwise. */
|
|
9
|
+
wait(): Promise<{
|
|
10
|
+
exitCode: number;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export interface CommandsApiStreamOptions {
|
|
14
|
+
onStdout?: (data: string) => void;
|
|
15
|
+
onStderr?: (data: string) => void;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/** The envd commands calls the process manager makes (E2B's `sandbox.commands`). */
|
|
19
|
+
export interface CommandsApi {
|
|
20
|
+
run(command: string, opts: CommandsApiStreamOptions & {
|
|
21
|
+
background: true;
|
|
22
|
+
stdin?: boolean;
|
|
23
|
+
cwd?: string;
|
|
24
|
+
envs?: Record<string, string>;
|
|
25
|
+
}): Promise<CommandsApiHandle>;
|
|
26
|
+
connect(pid: number, opts?: CommandsApiStreamOptions): Promise<CommandsApiHandle>;
|
|
27
|
+
/** Running commands only. */
|
|
28
|
+
list(): Promise<Array<{
|
|
29
|
+
pid: number;
|
|
30
|
+
cmd: string;
|
|
31
|
+
args: string[];
|
|
32
|
+
}>>;
|
|
33
|
+
kill(pid: number): Promise<boolean>;
|
|
34
|
+
sendStdin(pid: number, data: string): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Attaching sets no deadline of its own: without one the SDK cuts the stream
|
|
38
|
+
* after 60s, and the process's own timeout was set when it was spawned.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ATTACH_TIMEOUT_MS = 0;
|
|
41
|
+
export type CommandsApiOperation = 'spawn' | 'list' | 'connect' | 'kill' | 'sendStdin';
|
|
42
|
+
/**
|
|
43
|
+
* A process started or attached through a {@link CommandsApi}. `kill` and
|
|
44
|
+
* `sendStdin` go back through the manager, so they use whatever commands
|
|
45
|
+
* handle the provider currently supplies.
|
|
46
|
+
*/
|
|
47
|
+
export declare class CommandsApiProcessHandle extends ProcessHandle {
|
|
48
|
+
protected inner: CommandsApiHandle;
|
|
49
|
+
protected readonly manager: CommandsApiProcessManager<any>;
|
|
50
|
+
private readonly startTime;
|
|
51
|
+
private readonly stdinMode;
|
|
52
|
+
readonly pid: string;
|
|
53
|
+
/** The exit code `wait()` saw, for a handle that doesn't update its own. */
|
|
54
|
+
private waitedExitCode?;
|
|
55
|
+
constructor(inner: CommandsApiHandle, manager: CommandsApiProcessManager<any>, startTime: number, stdinMode: SpawnProcessOptions['stdinMode'], options?: SpawnProcessOptions);
|
|
56
|
+
/** Read from the commands handle, so it reflects server-side state without `wait()`. */
|
|
57
|
+
get exitCode(): number | undefined;
|
|
58
|
+
/** Wait for the process to exit. Providers whose output stream can drop while the process runs override this. */
|
|
59
|
+
protected waitForExit(): Promise<{
|
|
60
|
+
exitCode: number;
|
|
61
|
+
}>;
|
|
62
|
+
wait(): Promise<CommandResult>;
|
|
63
|
+
kill(): Promise<boolean>;
|
|
64
|
+
sendStdin(data: string): Promise<void>;
|
|
65
|
+
closeStdin(): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
export interface CommandsApiProcessManagerOptions {
|
|
68
|
+
env?: Record<string, string | undefined>;
|
|
69
|
+
/** Default timeout in milliseconds for commands that don't specify one. */
|
|
70
|
+
defaultTimeout?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A process manager over E2B's envd commands API. Providers supply the
|
|
74
|
+
* commands handle through {@link runCommands}; everything else is shared.
|
|
75
|
+
*/
|
|
76
|
+
export declare abstract class CommandsApiProcessManager<TSandbox extends MastraSandbox = MastraSandbox> extends SandboxProcessManager<TSandbox> {
|
|
77
|
+
protected readonly defaultTimeout?: number;
|
|
78
|
+
constructor({ defaultTimeout, ...options }?: CommandsApiProcessManagerOptions);
|
|
79
|
+
/** Run `fn` against the provider's current commands handle. */
|
|
80
|
+
abstract runCommands<T>(operation: CommandsApiOperation, fn: (commands: CommandsApi) => Promise<T>): Promise<T>;
|
|
81
|
+
/** Wrap a started or attached command. Providers override this to supply their own handle. */
|
|
82
|
+
protected createHandle(inner: CommandsApiHandle, stdinMode: SpawnProcessOptions['stdinMode'], options?: SpawnProcessOptions): CommandsApiProcessHandle;
|
|
83
|
+
/** Where a command runs when the caller gives no `cwd`. */
|
|
84
|
+
protected defaultCwd(): string | undefined;
|
|
85
|
+
spawn(command: string, options?: SpawnProcessOptions): Promise<ProcessHandle>;
|
|
86
|
+
/**
|
|
87
|
+
* Running processes as the VM reports them, plus exited processes this
|
|
88
|
+
* manager still holds, so a finished command stays visible until it is released.
|
|
89
|
+
*/
|
|
90
|
+
list(): Promise<ProcessInfo[]>;
|
|
91
|
+
/**
|
|
92
|
+
* A tracked process, or one this manager didn't start, attached through
|
|
93
|
+
* `connect`. Output from before attaching is not available.
|
|
94
|
+
*/
|
|
95
|
+
get(pid: string, _options?: {
|
|
96
|
+
release?: boolean;
|
|
97
|
+
}): Promise<ProcessHandle | undefined>;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=commands-api-process-manager.d.ts.map
|
|
@@ -2,4 +2,5 @@ export { SETUP_MARKER_DIR, SETUP_MARKER_PATH, WORKSPACE_SETUP_MARKER_PATH, SETUP
|
|
|
2
2
|
export { repoCloneCommand, type RepoCloneCommandOptions } from './repo-clone.js';
|
|
3
3
|
export { FILE_COMMAND_EXIT, shellQuote, siblingTempPath, copyCommand, moveNoClobberCommand, appendFromCommand, linkNoClobberCommand, type CopyCommandOptions, } from './file-commands.js';
|
|
4
4
|
export { FilesApiFilesystem, type FilesApi, type FilesApiEntry, type FilesApiErrorKind, type FilesCommandResult, } from './files-api-filesystem.js';
|
|
5
|
+
export { ATTACH_TIMEOUT_MS, CommandsApiProcessManager, CommandsApiProcessHandle, type CommandsApi, type CommandsApiHandle, type CommandsApiOperation, type CommandsApiProcessManagerOptions, type CommandsApiStreamOptions, } from './commands-api-process-manager.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/client.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface PlatformRequestOptions extends RequestInit {
|
|
|
23
23
|
}
|
|
24
24
|
export type SandboxProvider = 'railway' | 'e2b';
|
|
25
25
|
export declare function requireOption(value: string | undefined, name: string): string;
|
|
26
|
+
export declare function resolveSandboxProvider(value: string | undefined): SandboxProvider;
|
|
26
27
|
export declare function resolvePlatformOptions(options: PlatformClientOptions): {
|
|
27
28
|
accessToken: string;
|
|
28
29
|
projectId: string;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,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,CAAC,QAAQ,CAAC,CAEnF;IAEK,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE3F;YAEa,aAAa;CA2B5B"}
|
package/dist/e2b-exec.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CommandsApi } from './_types/@internal_workspace/dist/index.js';
|
|
1
2
|
import type { EntryInfo } from 'e2b';
|
|
2
3
|
import type { DirectExecOptions, DirectExecResult, ExecLease } from './direct-exec.js';
|
|
3
4
|
export interface E2BExecLease extends ExecLease {
|
|
@@ -23,6 +24,9 @@ export interface E2BFiles {
|
|
|
23
24
|
getInfo(path: string): Promise<EntryInfo>;
|
|
24
25
|
}
|
|
25
26
|
export type E2BFilesFactory = (lease: E2BExecLease) => E2BFiles;
|
|
27
|
+
export type E2BCommandsFactory = (lease: E2BExecLease) => CommandsApi;
|
|
26
28
|
/** Opens E2B's files API directly against the VM, authenticated by the exec lease. */
|
|
27
29
|
export declare const e2bFilesForLease: E2BFilesFactory;
|
|
30
|
+
/** Opens E2B's commands API directly against the VM, authenticated by the exec lease. */
|
|
31
|
+
export declare const commandsForLease: E2BCommandsFactory;
|
|
28
32
|
//# sourceMappingURL=e2b-exec.d.ts.map
|
package/dist/e2b-exec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e2b-exec.d.ts","sourceRoot":"","sources":["../src/e2b-exec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"e2b-exec.d.ts","sourceRoot":"","sources":["../src/e2b-exec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIvF,MAAM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