@mastra/editor 0.9.1-alpha.0 → 0.10.0-alpha.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/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Mastra } from '@mastra/core';
2
- import { GetByIdOptions, IEditorFavoritesNamespace, EditorFavoriteTargetInput, EditorFavoriteToggleResult, EditorIsFavoritedBatchInput, EditorListFavoritedIdsInput, FilesystemProvider, SandboxProvider, IMastraEditor, BlobStoreProvider, MastraEditorConfig } from '@mastra/core/editor';
3
- export { MastraEditorConfig } from '@mastra/core/editor';
2
+ import { IAgentBuilder } from '@mastra/core/agent-builder/ee';
3
+ import { GetByIdOptions, IEditorFavoritesNamespace, EditorFavoriteTargetInput, EditorFavoriteToggleResult, EditorIsFavoritedBatchInput, EditorListFavoritedIdsInput, FilesystemProvider, SandboxProvider, IMastraEditor, BlobStoreProvider, BrowserProvider, MastraEditorConfig } from '@mastra/core/editor';
4
+ export { BrowserProvider, MastraEditorConfig } from '@mastra/core/editor';
4
5
  import { IMastraLogger } from '@mastra/core/logger';
5
6
  import { ProcessorProvider } from '@mastra/core/processor-provider';
6
7
  import { StorageCreateAgentInput, StorageUpdateAgentInput, StorageListAgentsInput, StorageListAgentsOutput, StorageListAgentsResolvedOutput, StorageResolvedAgentType, StorageCreateMCPClientInput, StorageUpdateMCPClientInput, StorageListMCPClientsInput, StorageListMCPClientsOutput, StorageListMCPClientsResolvedOutput, StorageResolvedMCPClientType, StorageMCPServerConfig, StorageCreateMCPServerInput, StorageUpdateMCPServerInput, StorageListMCPServersInput, StorageListMCPServersOutput, StorageListMCPServersResolvedOutput, StorageResolvedMCPServerType, StorageCreatePromptBlockInput, StorageUpdatePromptBlockInput, StorageListPromptBlocksInput, StorageListPromptBlocksOutput, StorageListPromptBlocksResolvedOutput, StorageResolvedPromptBlockType, AgentInstructionBlock, StorageCreateScorerDefinitionInput, StorageUpdateScorerDefinitionInput, StorageListScorerDefinitionsInput, StorageListScorerDefinitionsOutput, StorageListScorerDefinitionsResolvedOutput, StorageResolvedScorerDefinitionType, StorageCreateWorkspaceInput, StorageUpdateWorkspaceInput, StorageListWorkspacesInput, StorageListWorkspacesOutput, StorageListWorkspacesResolvedOutput, StorageResolvedWorkspaceType, StorageWorkspaceSnapshotType, StorageCreateSkillInput, StorageUpdateSkillInput, StorageListSkillsInput, StorageListSkillsOutput, StorageListSkillsResolvedOutput, StorageResolvedSkillType, RuleGroup, PromptBlocksStorage, BlobStore } from '@mastra/core/storage';
@@ -95,6 +96,21 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
95
96
  * Hydrate a stored agent config into a runtime Agent instance.
96
97
  */
97
98
  protected hydrate(storedAgent: StorageResolvedAgentType): Promise<Agent>;
99
+ /**
100
+ * Create a new agent, applying builder defaults for fields not specified in input.
101
+ * Also ensures the referenced workspace (if any) is persisted as a stored workspace.
102
+ */
103
+ create(input: StorageCreateAgentInput): Promise<Agent>;
104
+ /**
105
+ * Ensure a workspace reference is persisted in the DB.
106
+ *
107
+ * For `type: 'id'`: looks up the runtime workspace, serializes its config,
108
+ * and creates a stored workspace record if one doesn't already exist.
109
+ *
110
+ * For `type: 'inline'`: derives a deterministic ID from the config and
111
+ * persists it as a stored workspace if one doesn't already exist.
112
+ */
113
+ private ensureStoredWorkspace;
98
114
  protected onCacheEvict(id: string): void;
99
115
  /**
100
116
  * Evict all cached agents that reference a given skill ID.
@@ -181,6 +197,7 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
181
197
  newName?: string;
182
198
  metadata?: Record<string, unknown>;
183
199
  authorId?: string;
200
+ visibility?: 'private' | 'public';
184
201
  requestContext?: RequestContext;
185
202
  }): Promise<StorageResolvedAgentType>;
186
203
  /**
@@ -193,6 +210,12 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
193
210
  * instead of filesystem-based discovery.
194
211
  */
195
212
  private resolveStoredWorkspace;
213
+ /**
214
+ * Resolve a stored browser config to a runtime MastraBrowser instance.
215
+ * Looks up the provider by ID in the editor's browser registry.
216
+ * Only supports `type: 'inline'` refs (config is embedded in the agent snapshot).
217
+ */
218
+ private resolveStoredBrowser;
196
219
  /**
197
220
  * Resolve agent-level skill configurations into a CompositeVersionedSkillSource.
198
221
  *
@@ -419,6 +442,9 @@ declare class MastraEditor implements IMastraEditor {
419
442
  __logger?: IMastraLogger;
420
443
  private __toolProviders;
421
444
  private __processorProviders;
445
+ private readonly __builderConfig?;
446
+ private __builderInstance?;
447
+ private __builderResolved;
422
448
  /**
423
449
  * @internal — exposed for namespace classes to hydrate stored workspace configs.
424
450
  * Maps provider ID (e.g., 'local', 's3') to the provider descriptor.
@@ -438,6 +464,12 @@ declare class MastraEditor implements IMastraEditor {
438
464
  * Additional providers come from config.
439
465
  */
440
466
  readonly __blobStores: Map<string, BlobStoreProvider>;
467
+ /**
468
+ * @internal — exposed for namespace classes to hydrate stored browser configs.
469
+ * Maps provider ID (e.g., 'stagehand', 'agent-browser') to the provider descriptor.
470
+ * No built-in providers — browser packages must be registered via config.
471
+ */
472
+ readonly __browsers: Map<string, BrowserProvider>;
441
473
  readonly agent: EditorAgentNamespace;
442
474
  readonly mcp: EditorMCPNamespace;
443
475
  readonly mcpServer: EditorMCPServerNamespace;
@@ -452,8 +484,50 @@ declare class MastraEditor implements IMastraEditor {
452
484
  * This gives the editor access to Mastra's storage, tools, workflows, etc.
453
485
  */
454
486
  registerWithMastra(mastra: Mastra): void;
487
+ /**
488
+ * Ensure the builder default workspace is persisted to the DB.
489
+ * Called automatically on startup when the editor registers with Mastra.
490
+ * Goes through the normal create() path so hydration validates that
491
+ * all providers (filesystem, sandbox) are properly registered.
492
+ *
493
+ * If the workspace already exists but its config has drifted from the
494
+ * runtime workspace, the DB record is updated (creating a new version).
495
+ * Builder-created workspaces are tagged with `metadata.source = 'builder'`
496
+ * so they can be identified during reconciliation.
497
+ */
498
+ private ensureBuilderWorkspaces;
499
+ /**
500
+ * Archive builder-created workspaces that no longer match the current
501
+ * builder configuration. Called after `ensureBuilderWorkspaces()` on startup.
502
+ *
503
+ * Only touches workspaces tagged with `metadata.source === 'builder'`.
504
+ * The current builder workspace (if any) is never archived.
505
+ */
506
+ private reconcileBuilderWorkspaces;
507
+ /**
508
+ * Sync. OSS-safe. Does NOT import @mastra/editor/ee.
509
+ * Returns true if builder config is present and enabled.
510
+ */
511
+ hasEnabledBuilderConfig(): boolean;
512
+ /**
513
+ * Async. Dynamic-imports @mastra/editor/ee on first call. Caches result.
514
+ * Returns undefined if builder is not enabled.
515
+ */
516
+ resolveBuilder(): Promise<IAgentBuilder | undefined>;
517
+ /**
518
+ * Defense-in-depth license guard for the Agent Builder. Mirrors the
519
+ * startup-time check in `MastraServer.validateAgentBuilderLicense()` so the
520
+ * builder cannot be instantiated outside the server boot path without a
521
+ * valid EE license. Dev environments bypass via `isEEEnabled()`.
522
+ */
523
+ private assertAgentBuilderLicensed;
455
524
  /** Registered tool providers */
456
525
  getToolProvider(id: string): ToolProvider | undefined;
526
+ /**
527
+ * Like {@link getToolProvider}, but throws {@link UnknownToolProviderError}
528
+ * when the id is unknown.
529
+ */
530
+ getToolProviderOrThrow(id: string): ToolProvider;
457
531
  /** List all registered tool providers */
458
532
  getToolProviders(): Record<string, ToolProvider>;
459
533
  /** Get a processor provider by ID */
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Mastra } from '@mastra/core';
2
- import { GetByIdOptions, IEditorFavoritesNamespace, EditorFavoriteTargetInput, EditorFavoriteToggleResult, EditorIsFavoritedBatchInput, EditorListFavoritedIdsInput, FilesystemProvider, SandboxProvider, IMastraEditor, BlobStoreProvider, MastraEditorConfig } from '@mastra/core/editor';
3
- export { MastraEditorConfig } from '@mastra/core/editor';
2
+ import { IAgentBuilder } from '@mastra/core/agent-builder/ee';
3
+ import { GetByIdOptions, IEditorFavoritesNamespace, EditorFavoriteTargetInput, EditorFavoriteToggleResult, EditorIsFavoritedBatchInput, EditorListFavoritedIdsInput, FilesystemProvider, SandboxProvider, IMastraEditor, BlobStoreProvider, BrowserProvider, MastraEditorConfig } from '@mastra/core/editor';
4
+ export { BrowserProvider, MastraEditorConfig } from '@mastra/core/editor';
4
5
  import { IMastraLogger } from '@mastra/core/logger';
5
6
  import { ProcessorProvider } from '@mastra/core/processor-provider';
6
7
  import { StorageCreateAgentInput, StorageUpdateAgentInput, StorageListAgentsInput, StorageListAgentsOutput, StorageListAgentsResolvedOutput, StorageResolvedAgentType, StorageCreateMCPClientInput, StorageUpdateMCPClientInput, StorageListMCPClientsInput, StorageListMCPClientsOutput, StorageListMCPClientsResolvedOutput, StorageResolvedMCPClientType, StorageMCPServerConfig, StorageCreateMCPServerInput, StorageUpdateMCPServerInput, StorageListMCPServersInput, StorageListMCPServersOutput, StorageListMCPServersResolvedOutput, StorageResolvedMCPServerType, StorageCreatePromptBlockInput, StorageUpdatePromptBlockInput, StorageListPromptBlocksInput, StorageListPromptBlocksOutput, StorageListPromptBlocksResolvedOutput, StorageResolvedPromptBlockType, AgentInstructionBlock, StorageCreateScorerDefinitionInput, StorageUpdateScorerDefinitionInput, StorageListScorerDefinitionsInput, StorageListScorerDefinitionsOutput, StorageListScorerDefinitionsResolvedOutput, StorageResolvedScorerDefinitionType, StorageCreateWorkspaceInput, StorageUpdateWorkspaceInput, StorageListWorkspacesInput, StorageListWorkspacesOutput, StorageListWorkspacesResolvedOutput, StorageResolvedWorkspaceType, StorageWorkspaceSnapshotType, StorageCreateSkillInput, StorageUpdateSkillInput, StorageListSkillsInput, StorageListSkillsOutput, StorageListSkillsResolvedOutput, StorageResolvedSkillType, RuleGroup, PromptBlocksStorage, BlobStore } from '@mastra/core/storage';
@@ -95,6 +96,21 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
95
96
  * Hydrate a stored agent config into a runtime Agent instance.
96
97
  */
97
98
  protected hydrate(storedAgent: StorageResolvedAgentType): Promise<Agent>;
99
+ /**
100
+ * Create a new agent, applying builder defaults for fields not specified in input.
101
+ * Also ensures the referenced workspace (if any) is persisted as a stored workspace.
102
+ */
103
+ create(input: StorageCreateAgentInput): Promise<Agent>;
104
+ /**
105
+ * Ensure a workspace reference is persisted in the DB.
106
+ *
107
+ * For `type: 'id'`: looks up the runtime workspace, serializes its config,
108
+ * and creates a stored workspace record if one doesn't already exist.
109
+ *
110
+ * For `type: 'inline'`: derives a deterministic ID from the config and
111
+ * persists it as a stored workspace if one doesn't already exist.
112
+ */
113
+ private ensureStoredWorkspace;
98
114
  protected onCacheEvict(id: string): void;
99
115
  /**
100
116
  * Evict all cached agents that reference a given skill ID.
@@ -181,6 +197,7 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
181
197
  newName?: string;
182
198
  metadata?: Record<string, unknown>;
183
199
  authorId?: string;
200
+ visibility?: 'private' | 'public';
184
201
  requestContext?: RequestContext;
185
202
  }): Promise<StorageResolvedAgentType>;
186
203
  /**
@@ -193,6 +210,12 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
193
210
  * instead of filesystem-based discovery.
194
211
  */
195
212
  private resolveStoredWorkspace;
213
+ /**
214
+ * Resolve a stored browser config to a runtime MastraBrowser instance.
215
+ * Looks up the provider by ID in the editor's browser registry.
216
+ * Only supports `type: 'inline'` refs (config is embedded in the agent snapshot).
217
+ */
218
+ private resolveStoredBrowser;
196
219
  /**
197
220
  * Resolve agent-level skill configurations into a CompositeVersionedSkillSource.
198
221
  *
@@ -419,6 +442,9 @@ declare class MastraEditor implements IMastraEditor {
419
442
  __logger?: IMastraLogger;
420
443
  private __toolProviders;
421
444
  private __processorProviders;
445
+ private readonly __builderConfig?;
446
+ private __builderInstance?;
447
+ private __builderResolved;
422
448
  /**
423
449
  * @internal — exposed for namespace classes to hydrate stored workspace configs.
424
450
  * Maps provider ID (e.g., 'local', 's3') to the provider descriptor.
@@ -438,6 +464,12 @@ declare class MastraEditor implements IMastraEditor {
438
464
  * Additional providers come from config.
439
465
  */
440
466
  readonly __blobStores: Map<string, BlobStoreProvider>;
467
+ /**
468
+ * @internal — exposed for namespace classes to hydrate stored browser configs.
469
+ * Maps provider ID (e.g., 'stagehand', 'agent-browser') to the provider descriptor.
470
+ * No built-in providers — browser packages must be registered via config.
471
+ */
472
+ readonly __browsers: Map<string, BrowserProvider>;
441
473
  readonly agent: EditorAgentNamespace;
442
474
  readonly mcp: EditorMCPNamespace;
443
475
  readonly mcpServer: EditorMCPServerNamespace;
@@ -452,8 +484,50 @@ declare class MastraEditor implements IMastraEditor {
452
484
  * This gives the editor access to Mastra's storage, tools, workflows, etc.
453
485
  */
454
486
  registerWithMastra(mastra: Mastra): void;
487
+ /**
488
+ * Ensure the builder default workspace is persisted to the DB.
489
+ * Called automatically on startup when the editor registers with Mastra.
490
+ * Goes through the normal create() path so hydration validates that
491
+ * all providers (filesystem, sandbox) are properly registered.
492
+ *
493
+ * If the workspace already exists but its config has drifted from the
494
+ * runtime workspace, the DB record is updated (creating a new version).
495
+ * Builder-created workspaces are tagged with `metadata.source = 'builder'`
496
+ * so they can be identified during reconciliation.
497
+ */
498
+ private ensureBuilderWorkspaces;
499
+ /**
500
+ * Archive builder-created workspaces that no longer match the current
501
+ * builder configuration. Called after `ensureBuilderWorkspaces()` on startup.
502
+ *
503
+ * Only touches workspaces tagged with `metadata.source === 'builder'`.
504
+ * The current builder workspace (if any) is never archived.
505
+ */
506
+ private reconcileBuilderWorkspaces;
507
+ /**
508
+ * Sync. OSS-safe. Does NOT import @mastra/editor/ee.
509
+ * Returns true if builder config is present and enabled.
510
+ */
511
+ hasEnabledBuilderConfig(): boolean;
512
+ /**
513
+ * Async. Dynamic-imports @mastra/editor/ee on first call. Caches result.
514
+ * Returns undefined if builder is not enabled.
515
+ */
516
+ resolveBuilder(): Promise<IAgentBuilder | undefined>;
517
+ /**
518
+ * Defense-in-depth license guard for the Agent Builder. Mirrors the
519
+ * startup-time check in `MastraServer.validateAgentBuilderLicense()` so the
520
+ * builder cannot be instantiated outside the server boot path without a
521
+ * valid EE license. Dev environments bypass via `isEEEnabled()`.
522
+ */
523
+ private assertAgentBuilderLicensed;
455
524
  /** Registered tool providers */
456
525
  getToolProvider(id: string): ToolProvider | undefined;
526
+ /**
527
+ * Like {@link getToolProvider}, but throws {@link UnknownToolProviderError}
528
+ * when the id is unknown.
529
+ */
530
+ getToolProviderOrThrow(id: string): ToolProvider;
457
531
  /** List all registered tool providers */
458
532
  getToolProviders(): Record<string, ToolProvider>;
459
533
  /** Get a processor provider by ID */