eve 0.12.1 → 0.12.2
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/CHANGELOG.md +6 -0
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiled/@vercel/sandbox/_async-retry.d.ts +8 -0
- package/dist/src/compiled/@vercel/sandbox/_workflow-serde.d.ts +5 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +1442 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/api-error.d.ts +29 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/base-client.d.ts +39 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/file-writer.d.ts +66 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +2 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +878 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/with-retry.d.ts +10 -0
- package/dist/src/compiled/@vercel/sandbox/auth/error.d.ts +15 -0
- package/dist/src/compiled/@vercel/sandbox/auth/file.d.ts +18 -0
- package/dist/src/compiled/@vercel/sandbox/auth/index.d.ts +6 -0
- package/dist/src/compiled/@vercel/sandbox/auth/oauth.d.ts +111 -0
- package/dist/src/compiled/@vercel/sandbox/auth/poll-for-token.d.ts +28 -0
- package/dist/src/compiled/@vercel/sandbox/auth/project.d.ts +40 -0
- package/dist/src/compiled/@vercel/sandbox/command.d.ts +290 -0
- package/dist/src/compiled/@vercel/sandbox/constants.d.ts +5 -0
- package/dist/src/compiled/@vercel/sandbox/filesystem.d.ts +258 -0
- package/dist/src/compiled/@vercel/sandbox/index.d.ts +10 -129
- package/dist/src/compiled/@vercel/sandbox/proxy.d.ts +55 -0
- package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +1058 -0
- package/dist/src/compiled/@vercel/sandbox/session.d.ts +432 -0
- package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +229 -0
- package/dist/src/compiled/@vercel/sandbox/utils/get-credentials.d.ts +21 -0
- package/dist/src/compiled/@vercel/sandbox/utils/paginator.d.ts +16 -0
- package/dist/src/compiled/@vercel/sandbox/utils/resolveSignal.d.ts +15 -0
- package/dist/src/compiled/@vercel/sandbox/utils/sandbox-snapshot.d.ts +11 -0
- package/dist/src/compiled/@vercel/sandbox/utils/types.d.ts +11 -0
- package/dist/src/compiled/chat/_workflow-serde.d.ts +3 -0
- package/dist/src/compiled/chat/index.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-base-runtime.d.ts +3 -3
- package/dist/src/execution/sandbox/bindings/vercel-create-sdk.d.ts +8 -13
- package/dist/src/execution/sandbox/bindings/vercel-credentials.d.ts +3 -3
- package/dist/src/execution/sandbox/bindings/vercel-lookup.d.ts +4 -5
- package/dist/src/execution/sandbox/bindings/vercel-read-stream.d.ts +5 -0
- package/dist/src/execution/sandbox/bindings/vercel-read-stream.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel-sdk-types.d.ts +6 -0
- package/dist/src/execution/sandbox/bindings/vercel-sdk-types.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +4 -4
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +12 -9
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/sandbox-network-policy.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Options } from "../_async-retry.js";
|
|
2
|
+
|
|
3
|
+
//#region src/api-client/with-retry.d.ts
|
|
4
|
+
interface RequestOptions {
|
|
5
|
+
onRetry?(error: any, options: RequestOptions): void;
|
|
6
|
+
retry?: Partial<Options>;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { RequestOptions };
|
|
10
|
+
//# sourceMappingURL=with-retry.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/auth/error.d.ts
|
|
2
|
+
declare class NotOk extends Error {
|
|
3
|
+
name: string;
|
|
4
|
+
response: {
|
|
5
|
+
statusCode: number;
|
|
6
|
+
responseText: string;
|
|
7
|
+
};
|
|
8
|
+
constructor(response: {
|
|
9
|
+
statusCode: number;
|
|
10
|
+
responseText: string;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { NotOk };
|
|
15
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "#compiled/zod/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/auth/file.d.ts
|
|
4
|
+
declare const AuthFile: z.ZodObject<{
|
|
5
|
+
token: z.ZodOptional<z.ZodString>;
|
|
6
|
+
refreshToken: z.ZodOptional<z.ZodString>;
|
|
7
|
+
expiresAt: z.ZodOptional<z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
type AuthFile = z.infer<typeof AuthFile>;
|
|
10
|
+
declare const getAuth: () => {
|
|
11
|
+
token?: string | undefined;
|
|
12
|
+
refreshToken?: string | undefined;
|
|
13
|
+
expiresAt?: Date | undefined;
|
|
14
|
+
} | null;
|
|
15
|
+
declare function updateAuthConfig(config: AuthFile): void;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getAuth, updateAuthConfig };
|
|
18
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { getAuth, updateAuthConfig } from "./file.js";
|
|
2
|
+
import { DeviceAuthorizationRequest, OAuth, isOAuthError } from "./oauth.js";
|
|
3
|
+
import { pollForToken } from "./poll-for-token.js";
|
|
4
|
+
import { inferScope } from "./project.js";
|
|
5
|
+
import { NotOk } from "./error.js";
|
|
6
|
+
export { DeviceAuthorizationRequest, NotOk, OAuth, getAuth, inferScope, isOAuthError, pollForToken, updateAuthConfig };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from "#compiled/zod/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/auth/oauth.d.ts
|
|
4
|
+
declare const IntrospectionResponse: z.ZodUnion<[z.ZodObject<{
|
|
5
|
+
active: z.ZodLiteral<true>;
|
|
6
|
+
client_id: z.ZodString;
|
|
7
|
+
session_id: z.ZodString;
|
|
8
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
+
active: z.ZodLiteral<false>;
|
|
10
|
+
}, z.core.$strip>]>;
|
|
11
|
+
declare function OAuth(): Promise<{
|
|
12
|
+
/**
|
|
13
|
+
* Perform the Device Authorization Request
|
|
14
|
+
*
|
|
15
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8628#section-3.1
|
|
16
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8628#section-3.2
|
|
17
|
+
*/
|
|
18
|
+
deviceAuthorizationRequest(): Promise<DeviceAuthorizationRequest>;
|
|
19
|
+
/**
|
|
20
|
+
* Perform the Device Access Token Request
|
|
21
|
+
*
|
|
22
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8628#section-3.4
|
|
23
|
+
*/
|
|
24
|
+
deviceAccessTokenRequest(device_code: string): Promise<[Error] | [null, Response]>;
|
|
25
|
+
/**
|
|
26
|
+
* Process the Token request Response
|
|
27
|
+
*
|
|
28
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8628#section-3.5
|
|
29
|
+
*/
|
|
30
|
+
processTokenResponse(response: Response): Promise<[OAuthError] | [null, TokenSet]>;
|
|
31
|
+
/**
|
|
32
|
+
* Perform a Token Revocation Request.
|
|
33
|
+
*
|
|
34
|
+
* @see https://datatracker.ietf.org/doc/html/rfc7009#section-2.1
|
|
35
|
+
* @see https://datatracker.ietf.org/doc/html/rfc7009#section-2.2
|
|
36
|
+
*/
|
|
37
|
+
revokeToken(token: string): Promise<OAuthError | void>;
|
|
38
|
+
/**
|
|
39
|
+
* Perform Refresh Token Request.
|
|
40
|
+
*
|
|
41
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-6
|
|
42
|
+
*/
|
|
43
|
+
refreshToken(token: string): Promise<TokenSet>;
|
|
44
|
+
/**
|
|
45
|
+
* Perform Token Introspection Request.
|
|
46
|
+
*
|
|
47
|
+
* @see https://datatracker.ietf.org/doc/html/rfc7662#section-2.1
|
|
48
|
+
*/
|
|
49
|
+
introspectToken(token: string): Promise<z.infer<typeof IntrospectionResponse>>;
|
|
50
|
+
}>;
|
|
51
|
+
type OAuth = Awaited<ReturnType<typeof OAuth>>;
|
|
52
|
+
declare const TokenSet: z.ZodObject<{
|
|
53
|
+
access_token: z.ZodString;
|
|
54
|
+
token_type: z.ZodLiteral<"Bearer">;
|
|
55
|
+
expires_in: z.ZodNumber;
|
|
56
|
+
refresh_token: z.ZodOptional<z.ZodString>;
|
|
57
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
type TokenSet = z.infer<typeof TokenSet>;
|
|
60
|
+
declare const OAuthErrorResponse: z.ZodObject<{
|
|
61
|
+
error: z.ZodEnum<{
|
|
62
|
+
invalid_request: "invalid_request";
|
|
63
|
+
invalid_client: "invalid_client";
|
|
64
|
+
invalid_grant: "invalid_grant";
|
|
65
|
+
unauthorized_client: "unauthorized_client";
|
|
66
|
+
unsupported_grant_type: "unsupported_grant_type";
|
|
67
|
+
invalid_scope: "invalid_scope";
|
|
68
|
+
server_error: "server_error";
|
|
69
|
+
authorization_pending: "authorization_pending";
|
|
70
|
+
slow_down: "slow_down";
|
|
71
|
+
access_denied: "access_denied";
|
|
72
|
+
expired_token: "expired_token";
|
|
73
|
+
unsupported_token_type: "unsupported_token_type";
|
|
74
|
+
}>;
|
|
75
|
+
error_description: z.ZodOptional<z.ZodString>;
|
|
76
|
+
error_uri: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
type OAuthErrorResponse = z.infer<typeof OAuthErrorResponse>;
|
|
79
|
+
declare class OAuthError extends Error {
|
|
80
|
+
name: string;
|
|
81
|
+
code: OAuthErrorResponse["error"];
|
|
82
|
+
cause: Error;
|
|
83
|
+
constructor(message: string, response: unknown);
|
|
84
|
+
}
|
|
85
|
+
declare function isOAuthError(error: unknown): error is OAuthError;
|
|
86
|
+
interface DeviceAuthorizationRequest {
|
|
87
|
+
/** The device verification code. */
|
|
88
|
+
device_code: string;
|
|
89
|
+
/** The end-user verification code. */
|
|
90
|
+
user_code: string;
|
|
91
|
+
/**
|
|
92
|
+
* The minimum amount of time in seconds that the client
|
|
93
|
+
* SHOULD wait between polling requests to the token endpoint.
|
|
94
|
+
*/
|
|
95
|
+
interval: number;
|
|
96
|
+
/** The end-user verification URI on the authorization server. */
|
|
97
|
+
verification_uri: string;
|
|
98
|
+
/**
|
|
99
|
+
* The end-user verification URI on the authorization server,
|
|
100
|
+
* including the `user_code`, without redirection.
|
|
101
|
+
*/
|
|
102
|
+
verification_uri_complete: string;
|
|
103
|
+
/**
|
|
104
|
+
* The absolute lifetime of the `device_code` and `user_code`.
|
|
105
|
+
* Calculated from `expires_in`.
|
|
106
|
+
*/
|
|
107
|
+
expiresAt: number;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { DeviceAuthorizationRequest, OAuth, isOAuthError };
|
|
111
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DeviceAuthorizationRequest, OAuth } from "./oauth.js";
|
|
2
|
+
|
|
3
|
+
//#region src/auth/poll-for-token.d.ts
|
|
4
|
+
type PollTokenItem = {
|
|
5
|
+
_tag: "Timeout";
|
|
6
|
+
newInterval: number;
|
|
7
|
+
} | {
|
|
8
|
+
_tag: "SlowDown";
|
|
9
|
+
newInterval: number;
|
|
10
|
+
} | {
|
|
11
|
+
_tag: "Error";
|
|
12
|
+
error: Error;
|
|
13
|
+
} | {
|
|
14
|
+
_tag: "Response";
|
|
15
|
+
response: {
|
|
16
|
+
text(): Promise<string>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
declare function pollForToken({
|
|
20
|
+
request,
|
|
21
|
+
oauth
|
|
22
|
+
}: {
|
|
23
|
+
request: DeviceAuthorizationRequest;
|
|
24
|
+
oauth: OAuth;
|
|
25
|
+
}): AsyncGenerator<PollTokenItem, void, void>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { pollForToken };
|
|
28
|
+
//# sourceMappingURL=poll-for-token.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/auth/project.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the team and project scope for sandbox operations.
|
|
4
|
+
*
|
|
5
|
+
* First checks for a locally linked project in `.vercel/project.json`.
|
|
6
|
+
* If found, uses the `projectId` and `orgId` from there.
|
|
7
|
+
*
|
|
8
|
+
* Otherwise, if `teamId` is not provided, builds an ordered list of candidate
|
|
9
|
+
* teams to try: the user's `defaultTeamId` first (if set), then hobby-plan
|
|
10
|
+
* teams where the user has an OWNER role (preferring the personal team matching
|
|
11
|
+
* the username, then the most recently updated). Tries each candidate until one
|
|
12
|
+
* succeeds.
|
|
13
|
+
*
|
|
14
|
+
* @param opts.token - Vercel API authentication token.
|
|
15
|
+
* @param opts.teamId - Optional team slug. If omitted, candidate teams are resolved automatically.
|
|
16
|
+
* @param opts.cwd - Optional directory to search for `.vercel/project.json`. Defaults to `process.cwd()`.
|
|
17
|
+
* @returns The resolved scope with `projectId`, `teamId`, and whether the project was `created`.
|
|
18
|
+
*
|
|
19
|
+
* @throws {NotOk} If the API returns an error other than 404 when checking the project.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const scope = await inferScope({ token: "vercel_..." });
|
|
24
|
+
* // => { projectId: "vercel-sandbox-default-project", teamId: "my-team", created: false }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function inferScope(opts: {
|
|
28
|
+
token: string;
|
|
29
|
+
teamId?: string;
|
|
30
|
+
cwd?: string;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
projectId: string;
|
|
33
|
+
teamId: string;
|
|
34
|
+
created: boolean;
|
|
35
|
+
teamSlug?: string;
|
|
36
|
+
projectSlug?: string;
|
|
37
|
+
}>;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { inferScope };
|
|
40
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { CommandData } from "./api-client/validators.js";
|
|
2
|
+
import { APIClient } from "./api-client/api-client.js";
|
|
3
|
+
import "./api-client/index.js";
|
|
4
|
+
import { Signal } from "./utils/resolveSignal.js";
|
|
5
|
+
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "./_workflow-serde.js";
|
|
6
|
+
|
|
7
|
+
//#region src/command.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Cached output from a command execution.
|
|
10
|
+
*/
|
|
11
|
+
interface CommandOutput {
|
|
12
|
+
stdout: string;
|
|
13
|
+
stderr: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Serialized representation of a Command for @workflow/serde.
|
|
17
|
+
*/
|
|
18
|
+
interface SerializedCommand {
|
|
19
|
+
sandboxId: string;
|
|
20
|
+
cmd: CommandData;
|
|
21
|
+
/** Cached output, included if output was fetched before serialization */
|
|
22
|
+
output?: CommandOutput;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Serialized representation of a CommandFinished for @workflow/serde.
|
|
26
|
+
*/
|
|
27
|
+
interface SerializedCommandFinished extends SerializedCommand {
|
|
28
|
+
exitCode: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A command executed in a Sandbox.
|
|
32
|
+
*
|
|
33
|
+
* For detached commands, you can {@link wait} to get a {@link CommandFinished} instance
|
|
34
|
+
* with the populated exit code. For non-detached commands, {@link Sandbox.runCommand}
|
|
35
|
+
* automatically waits and returns a {@link CommandFinished} instance.
|
|
36
|
+
*
|
|
37
|
+
* You can iterate over command output with {@link logs}.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link Sandbox.runCommand} to start a command.
|
|
40
|
+
*
|
|
41
|
+
* @hideconstructor
|
|
42
|
+
*/
|
|
43
|
+
declare class Command {
|
|
44
|
+
/**
|
|
45
|
+
* Cached API client instance.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
protected _client: APIClient | null;
|
|
49
|
+
/**
|
|
50
|
+
* Lazily resolve credentials and construct an API client.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
protected ensureClient(): Promise<APIClient>;
|
|
54
|
+
/**
|
|
55
|
+
* ID of the session this command is running in.
|
|
56
|
+
*/
|
|
57
|
+
protected sessionId: string;
|
|
58
|
+
/**
|
|
59
|
+
* Data for the command execution.
|
|
60
|
+
*/
|
|
61
|
+
protected cmd: CommandData;
|
|
62
|
+
exitCode: number | null;
|
|
63
|
+
protected outputCache: Promise<{
|
|
64
|
+
stdout: string;
|
|
65
|
+
stderr: string;
|
|
66
|
+
both: string;
|
|
67
|
+
}> | null;
|
|
68
|
+
/**
|
|
69
|
+
* Synchronously accessible resolved output, populated after output is fetched.
|
|
70
|
+
* Used for serialization.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
protected _resolvedOutput: CommandOutput | null;
|
|
74
|
+
/**
|
|
75
|
+
* ID of the command execution.
|
|
76
|
+
*/
|
|
77
|
+
get cmdId(): string;
|
|
78
|
+
get cwd(): string;
|
|
79
|
+
get startedAt(): number;
|
|
80
|
+
/**
|
|
81
|
+
* @param params - Object containing the client, sandbox ID, and command data.
|
|
82
|
+
* @param params.client - Optional API client. If not provided, will be lazily created using global credentials.
|
|
83
|
+
* @param params.sessionId - The ID of the session where the command is running.
|
|
84
|
+
* @param params.cmd - The command data.
|
|
85
|
+
* @param params.output - Optional cached output to restore (used during deserialization).
|
|
86
|
+
*/
|
|
87
|
+
constructor({
|
|
88
|
+
client,
|
|
89
|
+
sessionId,
|
|
90
|
+
cmd,
|
|
91
|
+
output
|
|
92
|
+
}: {
|
|
93
|
+
client?: APIClient;
|
|
94
|
+
sessionId: string;
|
|
95
|
+
cmd: CommandData;
|
|
96
|
+
output?: CommandOutput;
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Serialize a Command instance to plain data for @workflow/serde.
|
|
100
|
+
*
|
|
101
|
+
* @param instance - The Command instance to serialize
|
|
102
|
+
* @returns A plain object containing the sandbox ID, command data, and output if fetched
|
|
103
|
+
*/
|
|
104
|
+
static [WORKFLOW_SERIALIZE](instance: Command): SerializedCommand;
|
|
105
|
+
/**
|
|
106
|
+
* Deserialize plain data back into a Command instance for @workflow/serde.
|
|
107
|
+
*
|
|
108
|
+
* The deserialized instance will lazily create an API client using
|
|
109
|
+
* OIDC or environment credentials when needed.
|
|
110
|
+
*
|
|
111
|
+
* @param data - The serialized command data
|
|
112
|
+
* @returns The reconstructed Command instance
|
|
113
|
+
*/
|
|
114
|
+
static [WORKFLOW_DESERIALIZE](data: SerializedCommand): Command;
|
|
115
|
+
/**
|
|
116
|
+
* Iterate over the output of this command.
|
|
117
|
+
*
|
|
118
|
+
* ```
|
|
119
|
+
* for await (const log of cmd.logs()) {
|
|
120
|
+
* if (log.stream === "stdout") {
|
|
121
|
+
* process.stdout.write(log.data);
|
|
122
|
+
* } else {
|
|
123
|
+
* process.stderr.write(log.data);
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @param opts - Optional parameters.
|
|
129
|
+
* @param opts.signal - An AbortSignal to cancel log streaming.
|
|
130
|
+
* @returns An async iterable of log entries from the command output.
|
|
131
|
+
*
|
|
132
|
+
* @see {@link Command.stdout}, {@link Command.stderr}, and {@link Command.output}
|
|
133
|
+
* to access output as a string.
|
|
134
|
+
*/
|
|
135
|
+
logs(opts?: {
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
}): AsyncGenerator<{
|
|
138
|
+
data: string;
|
|
139
|
+
stream: "stdout";
|
|
140
|
+
} | {
|
|
141
|
+
data: string;
|
|
142
|
+
stream: "stderr";
|
|
143
|
+
}, void, void> & Disposable & {
|
|
144
|
+
close(): void;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Wait for a command to exit and populate its exit code.
|
|
148
|
+
*
|
|
149
|
+
* This method is useful for detached commands where you need to wait
|
|
150
|
+
* for completion. For non-detached commands, {@link Sandbox.runCommand}
|
|
151
|
+
* automatically waits and returns a {@link CommandFinished} instance.
|
|
152
|
+
*
|
|
153
|
+
* ```
|
|
154
|
+
* const detachedCmd = await sandbox.runCommand({ cmd: 'sleep', args: ['5'], detached: true });
|
|
155
|
+
* const result = await detachedCmd.wait();
|
|
156
|
+
* if (result.exitCode !== 0) {
|
|
157
|
+
* console.error("Something went wrong...")
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @param params - Optional parameters.
|
|
162
|
+
* @param params.signal - An AbortSignal to cancel waiting.
|
|
163
|
+
* @returns A {@link CommandFinished} instance with populated exit code.
|
|
164
|
+
*/
|
|
165
|
+
wait(params?: {
|
|
166
|
+
signal?: AbortSignal;
|
|
167
|
+
}): Promise<CommandFinished>;
|
|
168
|
+
/**
|
|
169
|
+
* Get cached output, fetching logs only once and reusing for concurrent calls.
|
|
170
|
+
* This prevents race conditions when stdout() and stderr() are called in parallel.
|
|
171
|
+
*/
|
|
172
|
+
protected getCachedOutput(opts?: {
|
|
173
|
+
signal?: AbortSignal;
|
|
174
|
+
}): Promise<{
|
|
175
|
+
stdout: string;
|
|
176
|
+
stderr: string;
|
|
177
|
+
both: string;
|
|
178
|
+
}>;
|
|
179
|
+
/**
|
|
180
|
+
* Get the output of `stdout`, `stderr`, or both as a string.
|
|
181
|
+
*
|
|
182
|
+
* NOTE: This may throw string conversion errors if the command does
|
|
183
|
+
* not output valid Unicode.
|
|
184
|
+
*
|
|
185
|
+
* @param stream - The output stream to read: "stdout", "stderr", or "both".
|
|
186
|
+
* @param opts - Optional parameters.
|
|
187
|
+
* @param opts.signal - An AbortSignal to cancel output streaming.
|
|
188
|
+
* @returns The output of the specified stream(s) as a string.
|
|
189
|
+
*/
|
|
190
|
+
output(stream?: "stdout" | "stderr" | "both", opts?: {
|
|
191
|
+
signal?: AbortSignal;
|
|
192
|
+
}): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Get the output of `stdout` as a string.
|
|
195
|
+
*
|
|
196
|
+
* NOTE: This may throw string conversion errors if the command does
|
|
197
|
+
* not output valid Unicode.
|
|
198
|
+
*
|
|
199
|
+
* @param opts - Optional parameters.
|
|
200
|
+
* @param opts.signal - An AbortSignal to cancel output streaming.
|
|
201
|
+
* @returns The standard output of the command.
|
|
202
|
+
*/
|
|
203
|
+
stdout(opts?: {
|
|
204
|
+
signal?: AbortSignal;
|
|
205
|
+
}): Promise<string>;
|
|
206
|
+
/**
|
|
207
|
+
* Get the output of `stderr` as a string.
|
|
208
|
+
*
|
|
209
|
+
* NOTE: This may throw string conversion errors if the command does
|
|
210
|
+
* not output valid Unicode.
|
|
211
|
+
*
|
|
212
|
+
* @param opts - Optional parameters.
|
|
213
|
+
* @param opts.signal - An AbortSignal to cancel output streaming.
|
|
214
|
+
* @returns The standard error output of the command.
|
|
215
|
+
*/
|
|
216
|
+
stderr(opts?: {
|
|
217
|
+
signal?: AbortSignal;
|
|
218
|
+
}): Promise<string>;
|
|
219
|
+
/**
|
|
220
|
+
* Kill a running command in a sandbox.
|
|
221
|
+
*
|
|
222
|
+
* @param signal - The signal to send the running process. Defaults to SIGTERM.
|
|
223
|
+
* @param opts - Optional parameters.
|
|
224
|
+
* @param opts.abortSignal - An AbortSignal to cancel the kill operation.
|
|
225
|
+
* @returns Promise<void>.
|
|
226
|
+
*/
|
|
227
|
+
kill(signal?: Signal, opts?: {
|
|
228
|
+
abortSignal?: AbortSignal;
|
|
229
|
+
}): Promise<void>;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* A command that has finished executing.
|
|
233
|
+
*
|
|
234
|
+
* The exit code is immediately available and populated upon creation.
|
|
235
|
+
* Unlike {@link Command}, you don't need to call wait() - the command
|
|
236
|
+
* has already completed execution.
|
|
237
|
+
*
|
|
238
|
+
* @hideconstructor
|
|
239
|
+
*/
|
|
240
|
+
declare class CommandFinished extends Command {
|
|
241
|
+
/**
|
|
242
|
+
* The exit code of the command. This is always populated for
|
|
243
|
+
* CommandFinished instances.
|
|
244
|
+
*/
|
|
245
|
+
exitCode: number;
|
|
246
|
+
/**
|
|
247
|
+
* @param params - Object containing client, sandbox ID, command data, and exit code.
|
|
248
|
+
* @param params.client - Optional API client. If not provided, will be lazily created using global credentials.
|
|
249
|
+
* @param params.sessionId - The ID of the session where the command ran.
|
|
250
|
+
* @param params.cmd - The command data.
|
|
251
|
+
* @param params.exitCode - The exit code of the completed command.
|
|
252
|
+
* @param params.output - Optional cached output to restore (used during deserialization).
|
|
253
|
+
*/
|
|
254
|
+
constructor(params: {
|
|
255
|
+
client?: APIClient;
|
|
256
|
+
sessionId: string;
|
|
257
|
+
cmd: CommandData;
|
|
258
|
+
exitCode: number;
|
|
259
|
+
output?: CommandOutput;
|
|
260
|
+
});
|
|
261
|
+
/**
|
|
262
|
+
* Serialize a CommandFinished instance to plain data for @workflow/serde.
|
|
263
|
+
*
|
|
264
|
+
* @param instance - The CommandFinished instance to serialize
|
|
265
|
+
* @returns A plain object containing the sandbox ID, command data, exit code, and output if fetched
|
|
266
|
+
*/
|
|
267
|
+
static [WORKFLOW_SERIALIZE](instance: CommandFinished): SerializedCommandFinished;
|
|
268
|
+
/**
|
|
269
|
+
* Deserialize plain data back into a CommandFinished instance for @workflow/serde.
|
|
270
|
+
*
|
|
271
|
+
* The deserialized instance will lazily create an API client using
|
|
272
|
+
* OIDC or environment credentials when needed.
|
|
273
|
+
*
|
|
274
|
+
* @param data - The serialized command finished data
|
|
275
|
+
* @returns The reconstructed CommandFinished instance
|
|
276
|
+
*/
|
|
277
|
+
static [WORKFLOW_DESERIALIZE](data: SerializedCommandFinished): CommandFinished;
|
|
278
|
+
/**
|
|
279
|
+
* The wait method is not needed for CommandFinished instances since
|
|
280
|
+
* the command has already completed and exitCode is populated.
|
|
281
|
+
*
|
|
282
|
+
* @deprecated This method is redundant for CommandFinished instances.
|
|
283
|
+
* The exitCode is already available.
|
|
284
|
+
* @returns This CommandFinished instance.
|
|
285
|
+
*/
|
|
286
|
+
wait(): Promise<CommandFinished>;
|
|
287
|
+
}
|
|
288
|
+
//#endregion
|
|
289
|
+
export { Command, CommandFinished, CommandOutput, SerializedCommand, SerializedCommandFinished };
|
|
290
|
+
//# sourceMappingURL=command.d.ts.map
|