@mastra/editor 0.11.0-alpha.2 → 0.11.0-alpha.4
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 +44 -0
- package/dist/ee/index.cjs +13 -17
- package/dist/ee/index.cjs.map +1 -1
- package/dist/ee/index.d.cts +2 -2
- package/dist/ee/index.d.ts +2 -2
- package/dist/ee/index.js +13 -17
- package/dist/ee/index.js.map +1 -1
- package/dist/index.cjs +81 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +68 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -156,6 +156,7 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
|
|
|
156
156
|
private accumulateObjectVariants;
|
|
157
157
|
private createAgentFromStoredConfig;
|
|
158
158
|
private resolveStoredInstructions;
|
|
159
|
+
private applyStoredToolDescriptions;
|
|
159
160
|
/**
|
|
160
161
|
* Resolve stored tool IDs to actual tool instances from Mastra's registry.
|
|
161
162
|
* Applies description overrides from per-tool config when present.
|
|
@@ -442,6 +443,8 @@ declare class MastraEditor implements IMastraEditor {
|
|
|
442
443
|
__logger?: IMastraLogger;
|
|
443
444
|
private __toolProviders;
|
|
444
445
|
private __processorProviders;
|
|
446
|
+
private __source?;
|
|
447
|
+
private __codePath;
|
|
445
448
|
private readonly __builderConfig?;
|
|
446
449
|
private __builderInstance?;
|
|
447
450
|
private __builderResolved;
|
|
@@ -521,6 +524,8 @@ declare class MastraEditor implements IMastraEditor {
|
|
|
521
524
|
* valid EE license. Dev environments bypass via `isEEEnabled()`.
|
|
522
525
|
*/
|
|
523
526
|
private assertAgentBuilderLicensed;
|
|
527
|
+
/** Returns the editor's configured source, or undefined if unset. */
|
|
528
|
+
getSource(): 'code' | 'db' | undefined;
|
|
524
529
|
/** Registered tool providers */
|
|
525
530
|
getToolProvider(id: string): ToolProvider | undefined;
|
|
526
531
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -156,6 +156,7 @@ declare class EditorAgentNamespace extends CrudEditorNamespace<StorageCreateAgen
|
|
|
156
156
|
private accumulateObjectVariants;
|
|
157
157
|
private createAgentFromStoredConfig;
|
|
158
158
|
private resolveStoredInstructions;
|
|
159
|
+
private applyStoredToolDescriptions;
|
|
159
160
|
/**
|
|
160
161
|
* Resolve stored tool IDs to actual tool instances from Mastra's registry.
|
|
161
162
|
* Applies description overrides from per-tool config when present.
|
|
@@ -442,6 +443,8 @@ declare class MastraEditor implements IMastraEditor {
|
|
|
442
443
|
__logger?: IMastraLogger;
|
|
443
444
|
private __toolProviders;
|
|
444
445
|
private __processorProviders;
|
|
446
|
+
private __source?;
|
|
447
|
+
private __codePath;
|
|
445
448
|
private readonly __builderConfig?;
|
|
446
449
|
private __builderInstance?;
|
|
447
450
|
private __builderResolved;
|
|
@@ -521,6 +524,8 @@ declare class MastraEditor implements IMastraEditor {
|
|
|
521
524
|
* valid EE license. Dev environments bypass via `isEEEnabled()`.
|
|
522
525
|
*/
|
|
523
526
|
private assertAgentBuilderLicensed;
|
|
527
|
+
/** Returns the editor's configured source, or undefined if unset. */
|
|
528
|
+
getSource(): 'code' | 'db' | undefined;
|
|
524
529
|
/** Registered tool providers */
|
|
525
530
|
getToolProvider(id: string): ToolProvider | undefined;
|
|
526
531
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { BUILT_IN_PROCESSOR_PROVIDERS } from "@mastra/core/processor-provider";
|
|
3
|
+
import { FilesystemStore, MastraCompositeStore } from "@mastra/core/storage";
|
|
3
4
|
import { UnknownToolProviderError } from "@mastra/core/tool-provider";
|
|
4
5
|
|
|
5
6
|
// src/namespaces/base.ts
|
|
@@ -703,6 +704,14 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
|
|
|
703
704
|
* Returns the (possibly mutated) agent.
|
|
704
705
|
*/
|
|
705
706
|
async applyStoredOverrides(agent, options, requestContext) {
|
|
707
|
+
const editorConfig = agent.__getEditorConfig?.();
|
|
708
|
+
if (editorConfig === false) {
|
|
709
|
+
return agent;
|
|
710
|
+
}
|
|
711
|
+
const instructionsEditable = editorConfig === void 0 ? true : editorConfig.instructions === true;
|
|
712
|
+
const toolsConfig = editorConfig === void 0 ? true : editorConfig.tools;
|
|
713
|
+
const toolsEditable = toolsConfig === true;
|
|
714
|
+
const toolDescriptionsEditable = typeof toolsConfig === "object" && toolsConfig !== null && toolsConfig.description === true;
|
|
706
715
|
let storedConfig = null;
|
|
707
716
|
try {
|
|
708
717
|
this.ensureRegistered();
|
|
@@ -724,7 +733,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
|
|
|
724
733
|
}
|
|
725
734
|
const fork = agent.__fork();
|
|
726
735
|
this.logger?.debug(`[applyStoredOverrides] Applying stored overrides to code agent "${agent.id}"`);
|
|
727
|
-
if (storedConfig.instructions !== void 0 && storedConfig.instructions !== null) {
|
|
736
|
+
if (instructionsEditable && storedConfig.instructions !== void 0 && storedConfig.instructions !== null) {
|
|
728
737
|
const resolved = this.resolveStoredInstructions(storedConfig.instructions);
|
|
729
738
|
if (resolved !== void 0) {
|
|
730
739
|
fork.__updateInstructions(resolved);
|
|
@@ -734,7 +743,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
|
|
|
734
743
|
const hasStoredMCPClients = storedConfig.mcpClients != null;
|
|
735
744
|
const hasStoredIntegrationTools = storedConfig.integrationTools != null;
|
|
736
745
|
const hasStoredToolProviders = storedConfig.toolProviders != null && Object.keys(storedConfig.toolProviders).length > 0;
|
|
737
|
-
if (hasStoredTools || hasStoredMCPClients || hasStoredIntegrationTools || hasStoredToolProviders) {
|
|
746
|
+
if (toolsEditable && (hasStoredTools || hasStoredMCPClients || hasStoredIntegrationTools || hasStoredToolProviders)) {
|
|
738
747
|
const hasConditionalTools = this.isConditionalVariants(storedConfig.tools);
|
|
739
748
|
const hasConditionalMCPClients = storedConfig.mcpClients != null && this.isConditionalVariants(storedConfig.mcpClients);
|
|
740
749
|
const hasConditionalIntegrationTools = storedConfig.integrationTools != null && this.isConditionalVariants(storedConfig.integrationTools);
|
|
@@ -793,6 +802,28 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
|
|
|
793
802
|
);
|
|
794
803
|
fork.__setTools({ ...codeTools, ...registryTools, ...mcpTools, ...integrationTools });
|
|
795
804
|
}
|
|
805
|
+
} else if (toolDescriptionsEditable && hasStoredTools) {
|
|
806
|
+
const hasConditionalTools = this.isConditionalVariants(storedConfig.tools);
|
|
807
|
+
if (hasConditionalTools) {
|
|
808
|
+
const originalTools = agent.listTools.bind(agent);
|
|
809
|
+
const toolsFn = async ({ requestContext: requestContext2 }) => {
|
|
810
|
+
const codeTools = await originalTools({ requestContext: requestContext2 });
|
|
811
|
+
const resolvedToolsConfig = this.accumulateObjectVariants(
|
|
812
|
+
storedConfig.tools,
|
|
813
|
+
requestContext2.toJSON()
|
|
814
|
+
);
|
|
815
|
+
return this.applyStoredToolDescriptions(codeTools, resolvedToolsConfig);
|
|
816
|
+
};
|
|
817
|
+
fork.__setTools(toolsFn);
|
|
818
|
+
} else {
|
|
819
|
+
const codeTools = await fork.listTools();
|
|
820
|
+
fork.__setTools(
|
|
821
|
+
this.applyStoredToolDescriptions(
|
|
822
|
+
codeTools,
|
|
823
|
+
storedConfig.tools
|
|
824
|
+
)
|
|
825
|
+
);
|
|
826
|
+
}
|
|
796
827
|
}
|
|
797
828
|
if (storedConfig.resolvedVersionId) {
|
|
798
829
|
const existing = fork.toRawConfig() ?? {};
|
|
@@ -1093,6 +1124,20 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
|
|
|
1093
1124
|
return resolveInstructionBlocks(blocks, context, { promptBlocksStorage: promptBlocksStore });
|
|
1094
1125
|
};
|
|
1095
1126
|
}
|
|
1127
|
+
applyStoredToolDescriptions(codeTools, storedTools) {
|
|
1128
|
+
if (!storedTools || Array.isArray(storedTools)) {
|
|
1129
|
+
return codeTools;
|
|
1130
|
+
}
|
|
1131
|
+
let nextTools;
|
|
1132
|
+
for (const [toolKey, toolConfig] of Object.entries(storedTools)) {
|
|
1133
|
+
if (!toolConfig.description || !(toolKey in codeTools)) {
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
nextTools ?? (nextTools = { ...codeTools });
|
|
1137
|
+
nextTools[toolKey] = { ...codeTools[toolKey], description: toolConfig.description };
|
|
1138
|
+
}
|
|
1139
|
+
return nextTools ?? codeTools;
|
|
1140
|
+
}
|
|
1096
1141
|
/**
|
|
1097
1142
|
* Resolve stored tool IDs to actual tool instances from Mastra's registry.
|
|
1098
1143
|
* Applies description overrides from per-tool config when present.
|
|
@@ -2207,6 +2252,8 @@ var MastraEditor = class {
|
|
|
2207
2252
|
this.__logger = config?.logger;
|
|
2208
2253
|
this.__toolProviders = config?.toolProviders ?? {};
|
|
2209
2254
|
this.__processorProviders = { ...BUILT_IN_PROCESSOR_PROVIDERS, ...config?.processorProviders };
|
|
2255
|
+
this.__source = config?.source;
|
|
2256
|
+
this.__codePath = config?.codePath ?? "./mastra/editor";
|
|
2210
2257
|
this.__filesystems = /* @__PURE__ */ new Map();
|
|
2211
2258
|
this.__filesystems.set(localFilesystemProvider.id, localFilesystemProvider);
|
|
2212
2259
|
for (const [id, provider] of Object.entries(config?.filesystems ?? {})) {
|
|
@@ -2244,6 +2291,21 @@ var MastraEditor = class {
|
|
|
2244
2291
|
if (!this.__logger) {
|
|
2245
2292
|
this.__logger = mastra.getLogger();
|
|
2246
2293
|
}
|
|
2294
|
+
if (this.__source === "code") {
|
|
2295
|
+
const filesystemStore = new FilesystemStore({ dir: this.__codePath });
|
|
2296
|
+
const existingStorage = mastra.getStorage();
|
|
2297
|
+
if (existingStorage) {
|
|
2298
|
+
mastra.setStorage(
|
|
2299
|
+
new MastraCompositeStore({
|
|
2300
|
+
id: `${existingStorage.id}-with-editor-filesystem`,
|
|
2301
|
+
default: existingStorage,
|
|
2302
|
+
editor: filesystemStore
|
|
2303
|
+
})
|
|
2304
|
+
);
|
|
2305
|
+
} else {
|
|
2306
|
+
mastra.setStorage(filesystemStore);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2247
2309
|
this.ensureBuilderWorkspaces().then(() => this.reconcileBuilderWorkspaces()).catch((err) => {
|
|
2248
2310
|
this.__logger?.warn("[MastraEditor] Failed to persist/reconcile builder workspaces on startup", {
|
|
2249
2311
|
error: err
|
|
@@ -2392,6 +2454,10 @@ var MastraEditor = class {
|
|
|
2392
2454
|
);
|
|
2393
2455
|
}
|
|
2394
2456
|
}
|
|
2457
|
+
/** Returns the editor's configured source, or undefined if unset. */
|
|
2458
|
+
getSource() {
|
|
2459
|
+
return this.__source;
|
|
2460
|
+
}
|
|
2395
2461
|
/** Registered tool providers */
|
|
2396
2462
|
getToolProvider(id) {
|
|
2397
2463
|
return this.__toolProviders[id];
|