@mastra/platform-workspace 1.13.2-alpha.0 → 1.14.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/client.d.ts +7 -4
- package/dist/e2b-exec.d.ts +1 -1
- package/dist/index.cjs +18 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -2
- package/dist/sandbox-filesystem.d.ts +2 -2
- package/dist/sandbox.d.ts +1 -1
- package/package.json +5 -5
- /package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/dist/commands-api-process-manager.d.ts +0 -0
- /package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/dist/file-commands.d.ts +0 -0
- /package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/dist/files-api-filesystem.d.ts +0 -0
- /package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/dist/repo-clone.d.ts +0 -0
- /package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/dist/setup-marker.d.ts +0 -0
- /package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/package.json +0 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/** A Platform access token, or a function that returns a fresh one for each request. */
|
|
2
|
+
export type PlatformAccessToken = string | (() => string | Promise<string>);
|
|
1
3
|
export interface PlatformClientOptions {
|
|
2
|
-
|
|
4
|
+
/** A token, or a function called before every request so long-lived sandboxes never hold an expired one. */
|
|
5
|
+
accessToken?: PlatformAccessToken;
|
|
3
6
|
projectId?: string;
|
|
4
7
|
actingUserId?: string;
|
|
5
8
|
sandboxProvider?: SandboxProvider;
|
|
@@ -22,10 +25,10 @@ export interface PlatformRequestOptions extends RequestInit {
|
|
|
22
25
|
query?: Record<string, string | number | boolean | undefined>;
|
|
23
26
|
}
|
|
24
27
|
export type SandboxProvider = 'railway' | 'e2b';
|
|
25
|
-
export declare function requireOption(value:
|
|
28
|
+
export declare function requireOption<T>(value: T | undefined, name: string): T;
|
|
26
29
|
export declare function resolveSandboxProvider(value: string | undefined): SandboxProvider;
|
|
27
30
|
export declare function resolvePlatformOptions(options: PlatformClientOptions): {
|
|
28
|
-
accessToken: string;
|
|
31
|
+
accessToken: string | (() => string | Promise<string>);
|
|
29
32
|
projectId: string;
|
|
30
33
|
actingUserId: string | undefined;
|
|
31
34
|
proxyUrl: string;
|
|
@@ -55,7 +58,7 @@ export declare class PlatformApiError extends Error {
|
|
|
55
58
|
constructor(status: number, body: string);
|
|
56
59
|
}
|
|
57
60
|
export declare class PlatformClient {
|
|
58
|
-
readonly accessToken:
|
|
61
|
+
readonly accessToken: PlatformAccessToken;
|
|
59
62
|
readonly projectId: string;
|
|
60
63
|
readonly actingUserId: string | undefined;
|
|
61
64
|
readonly proxyUrl: string;
|
package/dist/e2b-exec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommandsApi } from './_types/@internal_workspace@0.0.
|
|
1
|
+
import type { CommandsApi } from './_types/@internal_workspace@0.0.24/dist/index.js';
|
|
2
2
|
import type { EntryInfo } from 'e2b';
|
|
3
3
|
import type { DirectExecOptions, DirectExecResult, ExecLease } from './direct-exec.js';
|
|
4
4
|
export interface E2BExecLease extends ExecLease {
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
+
let events = require("events");
|
|
23
24
|
let buffer = require("buffer");
|
|
24
25
|
let path = require("path");
|
|
25
26
|
path = __toESM(path, 1);
|
|
@@ -143,13 +144,28 @@ var PlatformClient = class {
|
|
|
143
144
|
async requestAtPath(providerPath, path, options) {
|
|
144
145
|
const url = new URL(`${this.proxyUrl}/v1${providerPath}/projects/${encodeURIComponent(this.projectId)}${path}`);
|
|
145
146
|
for (const [key, value] of Object.entries(options.query ?? {})) if (value !== void 0) url.searchParams.set(key, String(value));
|
|
147
|
+
const signal = options.signal ?? AbortSignal.timeout(DEFAULT_REQUEST_TIMEOUT_MS);
|
|
148
|
+
signal.throwIfAborted();
|
|
146
149
|
const headers = new Headers(options.headers);
|
|
147
|
-
|
|
150
|
+
const getToken = this.accessToken;
|
|
151
|
+
let token = getToken;
|
|
152
|
+
if (typeof getToken === "function") {
|
|
153
|
+
let listener;
|
|
154
|
+
const aborted = new Promise((_, reject) => {
|
|
155
|
+
listener = (0, events.addAbortListener)(signal, () => reject(signal.reason));
|
|
156
|
+
});
|
|
157
|
+
try {
|
|
158
|
+
token = await Promise.race([aborted, new Promise((resolve) => resolve(getToken.call(this)))]);
|
|
159
|
+
} finally {
|
|
160
|
+
listener?.[Symbol.dispose]();
|
|
161
|
+
}
|
|
162
|
+
signal.throwIfAborted();
|
|
163
|
+
}
|
|
164
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
148
165
|
if (this.actingUserId) headers.set("x-acting-user-id", this.actingUserId);
|
|
149
166
|
if (this.sessionId) headers.set("x-mastra-session-id", this.sessionId);
|
|
150
167
|
if (this.threadId) headers.set("x-mastra-thread-id", this.threadId);
|
|
151
168
|
const { query: _query, ...fetchOptions } = options;
|
|
152
|
-
const signal = fetchOptions.signal ?? AbortSignal.timeout(DEFAULT_REQUEST_TIMEOUT_MS);
|
|
153
169
|
const response = await this.fetch(url, {
|
|
154
170
|
...fetchOptions,
|
|
155
171
|
headers,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PlatformClient, PlatformApiError, type PlatformClientOptions, type PlatformProxyError, type SandboxProvider, } from './client.js';
|
|
1
|
+
export { PlatformClient, PlatformApiError, type PlatformAccessToken, type PlatformClientOptions, type PlatformProxyError, type SandboxProvider, } from './client.js';
|
|
2
2
|
export { PlatformFilesystem, type PlatformFilesystemOptions } from './filesystem.js';
|
|
3
3
|
export { Template, type AptInstallOptions, type JsonPrimitive, type JsonValue, type NpmInstallOptions, type PipInstallOptions, type SandboxTemplateBuildOptions, type SandboxTemplateBuildResult, type SandboxTemplateBuilder, type SandboxTemplateMethod, type SetEnvsOptions, type SandboxTemplateOperation, type SerializedSandboxTemplate, } from './template.js';
|
|
4
4
|
export { PlatformSandbox, SandboxExecTransportError, SandboxDestroyedError, type PlatformSandboxOptions, type PlatformSandboxNetworkIsolation, type PlatformSandboxTemplate, type SandboxAddressRegistry, type SandboxPortAuthCookie, type SandboxTemplatePending, } from './sandbox.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addAbortListener } from "events";
|
|
1
2
|
import { Buffer as Buffer$1 } from "buffer";
|
|
2
3
|
import nodePath, { posix } from "path";
|
|
3
4
|
import { DirectoryNotEmptyError, DirectoryNotFoundError, FactorySandbox, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, MastraSandbox, NotDirectoryError, ProcessHandle, SandboxError, SandboxNotReadyError, SandboxProcessManager, UnsupportedStdinCloseError, WorkspaceReadOnlyError, getMimeType } from "@mastra/core/workspace";
|
|
@@ -120,13 +121,28 @@ var PlatformClient = class {
|
|
|
120
121
|
async requestAtPath(providerPath, path, options) {
|
|
121
122
|
const url = new URL(`${this.proxyUrl}/v1${providerPath}/projects/${encodeURIComponent(this.projectId)}${path}`);
|
|
122
123
|
for (const [key, value] of Object.entries(options.query ?? {})) if (value !== void 0) url.searchParams.set(key, String(value));
|
|
124
|
+
const signal = options.signal ?? AbortSignal.timeout(DEFAULT_REQUEST_TIMEOUT_MS);
|
|
125
|
+
signal.throwIfAborted();
|
|
123
126
|
const headers = new Headers(options.headers);
|
|
124
|
-
|
|
127
|
+
const getToken = this.accessToken;
|
|
128
|
+
let token = getToken;
|
|
129
|
+
if (typeof getToken === "function") {
|
|
130
|
+
let listener;
|
|
131
|
+
const aborted = new Promise((_, reject) => {
|
|
132
|
+
listener = addAbortListener(signal, () => reject(signal.reason));
|
|
133
|
+
});
|
|
134
|
+
try {
|
|
135
|
+
token = await Promise.race([aborted, new Promise((resolve) => resolve(getToken.call(this)))]);
|
|
136
|
+
} finally {
|
|
137
|
+
listener?.[Symbol.dispose]();
|
|
138
|
+
}
|
|
139
|
+
signal.throwIfAborted();
|
|
140
|
+
}
|
|
141
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
125
142
|
if (this.actingUserId) headers.set("x-acting-user-id", this.actingUserId);
|
|
126
143
|
if (this.sessionId) headers.set("x-mastra-session-id", this.sessionId);
|
|
127
144
|
if (this.threadId) headers.set("x-mastra-thread-id", this.threadId);
|
|
128
145
|
const { query: _query, ...fetchOptions } = options;
|
|
129
|
-
const signal = fetchOptions.signal ?? AbortSignal.timeout(DEFAULT_REQUEST_TIMEOUT_MS);
|
|
130
146
|
const response = await this.fetch(url, {
|
|
131
147
|
...fetchOptions,
|
|
132
148
|
headers,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FilesApiFilesystem } from './_types/@internal_workspace@0.0.
|
|
2
|
-
import type { FilesApi, FilesApiErrorKind, FilesCommandResult } from './_types/@internal_workspace@0.0.
|
|
1
|
+
import { FilesApiFilesystem } from './_types/@internal_workspace@0.0.24/dist/index.js';
|
|
2
|
+
import type { FilesApi, FilesApiErrorKind, FilesCommandResult } from './_types/@internal_workspace@0.0.24/dist/index.js';
|
|
3
3
|
import type { ProviderStatus } from '@mastra/core/workspace';
|
|
4
4
|
import type { E2BFiles } from './e2b-exec.js';
|
|
5
5
|
/** How `PlatformSandbox` lends its files API and shell to the filesystem. */
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommandsApi, CommandsApiOperation } from './_types/@internal_workspace@0.0.
|
|
1
|
+
import type { CommandsApi, CommandsApiOperation } from './_types/@internal_workspace@0.0.24/dist/index.js';
|
|
2
2
|
import type { RequestContext } from '@mastra/core/di';
|
|
3
3
|
import type { CommandResult, ExecuteCommandOptions, InstructionsOption, MastraSandboxOptions, ProviderStatus, SandboxCloneOptions, SandboxInfo, SandboxNetworking, SandboxStartResult } from '@mastra/core/workspace';
|
|
4
4
|
import { MastraSandbox, SandboxProcessManager } from '@mastra/core/workspace';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/platform-workspace",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Mastra Platform workspace sandbox and filesystem providers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"tsdown": "0.23.1",
|
|
27
27
|
"typescript": "^7.0.2",
|
|
28
28
|
"vitest": "5.1.0",
|
|
29
|
-
"@internal/
|
|
30
|
-
"@internal/
|
|
31
|
-
"@internal/
|
|
32
|
-
"@mastra/core": "1.86.0
|
|
29
|
+
"@internal/workspace": "0.0.24",
|
|
30
|
+
"@internal/lint": "0.0.152",
|
|
31
|
+
"@internal/types-builder": "0.0.127",
|
|
32
|
+
"@mastra/core": "1.86.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@mastra/core": ">=1.80.0-0 <2.0.0-0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/dist/index.d.ts
RENAMED
|
File without changes
|
/package/dist/_types/{@internal_workspace@0.0.23 → @internal_workspace@0.0.24}/dist/repo-clone.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|