@mastra/platform-workspace 1.12.0 → 1.13.0-alpha.1

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.
@@ -14,6 +14,8 @@ export interface PlatformFactorySandboxSettings extends Record<string, unknown>
14
14
  docker?: boolean;
15
15
  /** Minutes idle before the sandbox pauses. Runtime only. */
16
16
  idleTimeoutMinutes?: number;
17
+ /** Let anyone with a port's URL open it without signing in. Fixed when a sandbox is created. */
18
+ publicPorts?: boolean;
17
19
  }
18
20
  export interface PlatformFactorySandboxOptions extends Omit<PlatformSandboxOptions, 'id' | 'sandboxId' | 'sessionId' | 'template' | 'env'> {
19
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"factory-sandbox.d.ts","sourceRoot":"","sources":["../src/factory-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAIV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAG3D,uHAAuH;AACvH,MAAM,WAAW,8BAA+B,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7E,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAqED,MAAM,WAAW,6BAA8B,SAAQ,IAAI,CACzD,sBAAsB,EACtB,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QAAQ,CACN,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,8BAA8B,GACvC,4BAA4B,GAAG,SAAS,CAa1C;IAED,MAAM,CAAC,GAAG,EAAE,qBAAqB,EAAE,QAAQ,EAAE,8BAA8B,GAAG,eAAe,CAmB5F;CA4CF"}
package/dist/index.cjs CHANGED
@@ -1994,6 +1994,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1994
1994
  _templateResolutionInFlight;
1995
1995
  _idleTimeoutMinutes;
1996
1996
  _networkIsolation;
1997
+ _publicPorts;
1997
1998
  _env;
1998
1999
  _timeout;
1999
2000
  _instructionsOverride;
@@ -2092,6 +2093,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
2092
2093
  this._template = options.template;
2093
2094
  this._idleTimeoutMinutes = options.idleTimeoutMinutes;
2094
2095
  this._networkIsolation = options.networkIsolation;
2096
+ this._publicPorts = options.publicPorts;
2095
2097
  this._env = options.env ?? {};
2096
2098
  this._timeout = options.timeout;
2097
2099
  this._instructionsOverride = options.instructions;
@@ -2149,6 +2151,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
2149
2151
  ...this._template !== void 0 && { template: this._template },
2150
2152
  idleTimeoutMinutes: options.idleTimeoutMinutes ?? this._idleTimeoutMinutes,
2151
2153
  ...this._networkIsolation !== void 0 && { networkIsolation: this._networkIsolation },
2154
+ ...this._publicPorts !== void 0 && { publicPorts: this._publicPorts },
2152
2155
  env: options.env ?? this._env,
2153
2156
  ...this._timeout !== void 0 && { timeout: this._timeout },
2154
2157
  ...this._instructionsOverride !== void 0 && { instructions: this._instructionsOverride },
@@ -2204,6 +2207,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
2204
2207
  environmentId: this._environmentId,
2205
2208
  idleTimeoutMinutes: this._idleTimeoutMinutes,
2206
2209
  networkIsolation: this._networkIsolation,
2210
+ publicPorts: this._publicPorts,
2207
2211
  env: this._env
2208
2212
  });
2209
2213
  let response;
@@ -3145,6 +3149,7 @@ function createRepoTemplate(options) {
3145
3149
  for (const repo of repos) if (repo.tokenEnv && repo.token) buildEnv[repo.tokenEnv] = repo.token;
3146
3150
  if (Object.keys(buildEnv).length > 0) template = template.setEnvs(buildEnv, { ephemeral: true });
3147
3151
  template = withResources(template, options);
3152
+ if (options.buildEnvRevision) template = template.setEnvs({ MASTRA_BUILD_ENV_REVISION: options.buildEnvRevision });
3148
3153
  if (workingDirectory) template = template.runCmd(`mkdir -p "${workingDirectory}"`).setWorkdir(workingDirectory);
3149
3154
  const ordered = [...repos.filter((repo) => !repo.token), ...repos.filter((repo) => repo.token)];
3150
3155
  for (const repo of ordered) {
@@ -3343,6 +3348,11 @@ const platformSandboxProvider = {
3343
3348
  enum: ["ISOLATED", "PRIVATE"],
3344
3349
  default: "ISOLATED"
3345
3350
  },
3351
+ publicPorts: {
3352
+ type: "boolean",
3353
+ description: "Let anyone with a port URL reach it without signing in",
3354
+ default: false
3355
+ },
3346
3356
  env: {
3347
3357
  type: "object",
3348
3358
  description: "Environment variables",
@@ -3390,7 +3400,8 @@ const DEFAULT_SETTINGS = {
3390
3400
  cpuCount: 2,
3391
3401
  memoryMb: 1024,
3392
3402
  docker: false,
3393
- idleTimeoutMinutes: 5
3403
+ idleTimeoutMinutes: 5,
3404
+ publicPorts: false
3394
3405
  };
3395
3406
  const SETTINGS_SCHEMA = {
3396
3407
  type: "object",
@@ -3444,14 +3455,20 @@ const SETTINGS_SCHEMA = {
3444
3455
  default: DEFAULT_SETTINGS.idleTimeoutMinutes,
3445
3456
  minimum: 1,
3446
3457
  maximum: 1440
3458
+ },
3459
+ publicPorts: {
3460
+ type: "boolean",
3461
+ title: "Public preview links",
3462
+ description: "Anyone with a sandbox's preview link can open it without signing in. Applies to newly created sandboxes, not existing ones.",
3463
+ default: DEFAULT_SETTINGS.publicPorts
3447
3464
  }
3448
3465
  },
3449
3466
  additionalProperties: false
3450
3467
  };
3451
3468
  /**
3452
3469
  * The settings schema with the provider's effective defaults as `default`:
3453
- * the built-in values, overridden by the host's `idleTimeoutMinutes` option and
3454
- * then its `defaults` option. The schema
3470
+ * the built-in values, overridden by the host's `idleTimeoutMinutes` and
3471
+ * `publicPorts` options and then its `defaults` option. The schema
3455
3472
  * is what clients show as placeholders, so it must match what the provider
3456
3473
  * applies when a setting is unset.
3457
3474
  */
@@ -3497,14 +3514,21 @@ var PlatformFactorySandbox = class extends _mastra_core_workspace.FactorySandbox
3497
3514
  this.#options = options;
3498
3515
  this.settings = settingsSchema({
3499
3516
  ...options.idleTimeoutMinutes !== void 0 ? { idleTimeoutMinutes: options.idleTimeoutMinutes } : {},
3517
+ ...options.publicPorts !== void 0 ? { publicPorts: options.publicPorts } : {},
3500
3518
  ...options.defaults
3501
3519
  });
3502
3520
  }
3503
3521
  template(ctx, settings) {
3504
3522
  const { defaults, template } = this.#options;
3523
+ const { buildEnv, buildEnvRevision, ...rest } = ctx;
3524
+ const mergedBuildEnv = {
3525
+ ...template?.buildEnv,
3526
+ ...buildEnv
3527
+ };
3505
3528
  return createRepoTemplate({
3506
- ...ctx,
3507
- ...template?.buildEnv ? { buildEnv: template.buildEnv } : {},
3529
+ ...rest,
3530
+ ...Object.keys(mergedBuildEnv).length > 0 ? { buildEnv: mergedBuildEnv } : {},
3531
+ ...buildEnvRevision ? { buildEnvRevision } : {},
3508
3532
  cpuCount: settings.cpuCount ?? defaults?.cpuCount ?? DEFAULT_SETTINGS.cpuCount,
3509
3533
  memoryMB: settings.memoryMb ?? defaults?.memoryMb ?? DEFAULT_SETTINGS.memoryMb,
3510
3534
  docker: settings.docker ?? defaults?.docker ?? DEFAULT_SETTINGS.docker
@@ -3520,7 +3544,8 @@ var PlatformFactorySandbox = class extends _mastra_core_workspace.FactorySandbox
3520
3544
  sandboxId: ctx.sandboxId,
3521
3545
  template: this.template(ctx, settings),
3522
3546
  ...ctx.workingDirectory ? { workingDirectory: ctx.workingDirectory } : {},
3523
- idleTimeoutMinutes: settings.idleTimeoutMinutes ?? defaults?.idleTimeoutMinutes ?? options.idleTimeoutMinutes ?? DEFAULT_SETTINGS.idleTimeoutMinutes
3547
+ idleTimeoutMinutes: settings.idleTimeoutMinutes ?? defaults?.idleTimeoutMinutes ?? options.idleTimeoutMinutes ?? DEFAULT_SETTINGS.idleTimeoutMinutes,
3548
+ publicPorts: settings.publicPorts ?? defaults?.publicPorts ?? options.publicPorts ?? DEFAULT_SETTINGS.publicPorts
3524
3549
  });
3525
3550
  }
3526
3551
  async #startBuild(ctx, settings) {