babylonjs-editor 5.5.2-alpha.0 → 5.5.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.
Files changed (38) hide show
  1. package/build/src/index.js +1 -1
  2. package/declaration/src/editor/layout/assets-browser/events/gui.d.ts +7 -0
  3. package/declaration/src/editor/layout/assets-browser/events/material.d.ts +7 -0
  4. package/declaration/src/editor/layout/assets-browser/events/particles.d.ts +8 -0
  5. package/declaration/src/editor/layout/assets-browser/events/scene.d.ts +7 -0
  6. package/declaration/src/editor/layout/assets-browser.d.ts +1 -0
  7. package/declaration/src/editor/layout/assistant/agents.d.ts +47 -0
  8. package/declaration/src/editor/layout/assistant/antigravity.d.ts +107 -0
  9. package/declaration/src/editor/layout/assistant/claude.d.ts +30 -0
  10. package/declaration/src/editor/layout/assistant/codex.d.ts +84 -0
  11. package/declaration/src/editor/layout/assistant/config.d.ts +109 -0
  12. package/declaration/src/editor/layout/assistant/executable.d.ts +80 -0
  13. package/declaration/src/editor/layout/assistant/hooks.d.ts +105 -0
  14. package/declaration/src/editor/layout/assistant/icon.d.ts +21 -0
  15. package/declaration/src/editor/layout/assistant/skills.d.ts +33 -0
  16. package/declaration/src/editor/layout/assistant/watcher.d.ts +43 -0
  17. package/declaration/src/editor/layout/assistant.d.ts +142 -0
  18. package/declaration/src/editor/layout/console.d.ts +33 -0
  19. package/declaration/src/editor/layout/toolbar.d.ts +2 -0
  20. package/declaration/src/editor/layout.d.ts +22 -0
  21. package/declaration/src/editor/main.d.ts +19 -0
  22. package/declaration/src/editor/menu.d.ts +1 -0
  23. package/declaration/src/mcp/mcp.d.ts +46 -2
  24. package/declaration/src/mcp/meshes/decals.d.ts +28 -0
  25. package/declaration/src/mcp/play/keys.d.ts +26 -0
  26. package/declaration/src/mcp/play/play.d.ts +29 -0
  27. package/declaration/src/mcp/screenshot.d.ts +3 -2
  28. package/declaration/src/mcp/scripts/scripts.d.ts +3 -3
  29. package/declaration/src/mcp/scripts/values.d.ts +33 -0
  30. package/declaration/src/mcp/server.d.ts +49 -0
  31. package/declaration/src/mcp/tools/resolve.d.ts +1 -0
  32. package/declaration/src/project/agent-data.d.ts +21 -0
  33. package/declaration/src/project/save/save.d.ts +2 -0
  34. package/declaration/src/tools/local-storage.d.ts +20 -0
  35. package/declaration/src/tools/node-pty.d.ts +25 -5
  36. package/declaration/src/tools/scene/play/override.d.ts +6 -0
  37. package/declaration/src/ui/toolbar.d.ts +5 -1
  38. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Defines the name of the file the assistant writes in each skill it installs in a project. It holds the hash of the
3
+ * files installed, to know if the user modified the skill since.
4
+ */
5
+ export declare const assistantSkillMarkerFileName = ".babylonjs-editor-skill.json";
6
+ /**
7
+ * Defines what happened to a skill when installing it in a project:
8
+ * - "installed": the skill was not in the project and was copied.
9
+ * - "updated": the skill installed by the editor was replaced by the version of this editor.
10
+ * - "up-to-date": the skill installed by the editor is already the version of this editor.
11
+ * - "kept": the skill was modified by the user, or not installed by the editor, and was left as is.
12
+ */
13
+ export type AssistantSkillInstallResult = "installed" | "updated" | "up-to-date" | "kept";
14
+ /**
15
+ * Returns the hash of the files of the given skill, the file of the editor excluded.
16
+ * @param directory defines the absolute path of the folder of the skill.
17
+ */
18
+ export declare function getSkillHash(directory: string): Promise<string>;
19
+ /**
20
+ * Installs the given skill in the given folder, or updates the version the editor installed there before. A skill the
21
+ * user modified, or didn't come from the editor, is never replaced.
22
+ * @param sourceDirectory defines the absolute path of the folder of the skill bundled with the editor.
23
+ * @param targetDirectory defines the absolute path of the folder of the skill in the project.
24
+ */
25
+ export declare function installAssistantSkill(sourceDirectory: string, targetDirectory: string): Promise<AssistantSkillInstallResult>;
26
+ /**
27
+ * Installs the skills of the plugin of the assistant in the "agents" skills folder of the project ("<project>/.agents/skills"),
28
+ * where Codex finds the skills of a project: Codex can't load skills from another folder for a single session.
29
+ * @param pluginDirectory defines the absolute path of the plugin of the assistant bundled with the editor.
30
+ * @param projectDirectory defines the absolute path of the root folder of the project.
31
+ * @returns what happened to each skill, by name.
32
+ */
33
+ export declare function installAssistantSkillsInProject(pluginDirectory: string, projectDirectory: string): Promise<Record<string, AssistantSkillInstallResult>>;
@@ -0,0 +1,43 @@
1
+ import { Editor } from "../../main";
2
+ /**
3
+ * Returns wether or not changes of the given file of the assets folder are ignored: hidden files and caches, files
4
+ * generated by the editor, and the content of packages like scenes, which the editor rewrites each time it saves.
5
+ * @param relativePath defines the path of the file, relative to the assets folder, with forward slashes.
6
+ */
7
+ export declare function isIgnoredAssetPath(relativePath: string): boolean;
8
+ /**
9
+ * Watches the assets folder of the project while the AI assistant runs: the assets browser shows the files it adds,
10
+ * and the elements of the scene created from an asset it modifies are reloaded.
11
+ */
12
+ export declare class AssistantAssetsWatcher {
13
+ readonly editor: Editor;
14
+ readonly assetsDirectory: string;
15
+ private _watcher;
16
+ private _refreshTimeout;
17
+ private _reloadTimeouts;
18
+ private _hashes;
19
+ private _assetUpdatedTimes;
20
+ private _onAssetUpdated;
21
+ /**
22
+ * Constructor.
23
+ * @param editor defines the reference to the editor.
24
+ * @param assetsDirectory defines the absolute path of the assets folder of the project.
25
+ */
26
+ constructor(editor: Editor, assetsDirectory: string);
27
+ /**
28
+ * Starts watching the assets folder.
29
+ */
30
+ start(): void;
31
+ /**
32
+ * Stops watching the assets folder.
33
+ */
34
+ stop(): void;
35
+ private _scheduleRefresh;
36
+ private _scheduleReload;
37
+ private _reload;
38
+ /**
39
+ * Returns wether or not the given file was just written by the editor itself: while or right after saving the
40
+ * project, or right after another window of the editor saved an asset of the same type and updated the scene.
41
+ */
42
+ private _isWrittenByEditor;
43
+ }
@@ -0,0 +1,142 @@
1
+ import { Component, ReactNode } from "react";
2
+ import { Editor } from "../main";
3
+ import { IAssistantExecutable } from "./assistant/executable";
4
+ import { EditorAssistantAgentId } from "./assistant/agents";
5
+ export type EditorAssistantStatus = "idle" | "no-project" | "searching" | "not-found" | "starting" | "running" | "exited" | "error";
6
+ export interface IEditorAssistantProps {
7
+ /**
8
+ * Defines the reference to the editor.
9
+ */
10
+ editor: Editor;
11
+ /**
12
+ * Defines wether or not the panel of the assistant is open. The session starts the first time it opens and keeps
13
+ * running while it is closed.
14
+ */
15
+ open: boolean;
16
+ }
17
+ export interface IEditorAssistantState {
18
+ status: EditorAssistantStatus;
19
+ agent: EditorAssistantAgentId;
20
+ executable: IAssistantExecutable | null;
21
+ error: string | null;
22
+ exitCode: number | null;
23
+ activity: string | null;
24
+ dragOver: boolean;
25
+ welcome: boolean;
26
+ }
27
+ export declare class EditorAssistant extends Component<IEditorAssistantProps, IEditorAssistantState> {
28
+ private _terminal;
29
+ private _fitAddon;
30
+ private _webglAddon;
31
+ private _terminalContainer;
32
+ private _resizeObserver;
33
+ private _fitTimeout;
34
+ private _themeObserver;
35
+ private _pty;
36
+ private _mcpServer;
37
+ private _hooksServer;
38
+ private _watcher;
39
+ private _projectPath;
40
+ private _starting;
41
+ private _sessionAgent;
42
+ private _antigravityPluginRemoval;
43
+ private _antigravityOutput;
44
+ private _workState;
45
+ private _inputToastId;
46
+ private _sessionId;
47
+ private _activityTimeout;
48
+ private _projectConfigurationObserver;
49
+ constructor(props: IEditorAssistantProps);
50
+ render(): ReactNode;
51
+ componentDidMount(): void;
52
+ componentDidUpdate(prevProps: IEditorAssistantProps): void;
53
+ componentWillUnmount(): void;
54
+ /**
55
+ * Gets wether or not a session of the agent is running in the assistant.
56
+ */
57
+ get isRunning(): boolean;
58
+ /**
59
+ * Focuses the terminal of the assistant so the user can type directly.
60
+ */
61
+ focus(): void;
62
+ /**
63
+ * Starts a session of the agent chosen by the user in the root folder of the project, connected to this editor window.
64
+ * @param resume defines wether or not to continue the last conversation of the project instead of starting a new one.
65
+ */
66
+ start(resume: boolean): Promise<void>;
67
+ /**
68
+ * Returns the absolute path of the plugin of the assistant, holding the skills of the editor, or null when it was not
69
+ * built.
70
+ */
71
+ private _getPluginDirectory;
72
+ /**
73
+ * Installs the skills of the editor in the project for Codex, which only finds skills in the project or in the home
74
+ * folder of the user. The agent still starts when they can't be installed.
75
+ */
76
+ private _installSkillsInProject;
77
+ /**
78
+ * Stops the current session of the agent, if any, and starts a new one.
79
+ * @param resume defines wether or not to continue the last conversation of the project instead of starting a new one.
80
+ */
81
+ restart(resume: boolean): Promise<void>;
82
+ private _stopSession;
83
+ /**
84
+ * Removes the plugin given to Antigravity CLI, once no session of the assistant uses it anymore, so the other
85
+ * sessions of Antigravity CLI of the user don't start the MCP server of the editor.
86
+ */
87
+ private _removeAntigravityPlugin;
88
+ /**
89
+ * Starts the HTTP server the hook events of the new session are sent to. Each session has its own server, so the
90
+ * events a stopped session still sends are never received.
91
+ */
92
+ private _startHooksServer;
93
+ private _stopHooksServer;
94
+ private _setWorkState;
95
+ private _handleHook;
96
+ private _handleAntigravityHook;
97
+ /**
98
+ * Follows the output of Antigravity CLI while it works to know when it waits for the user to allow a tool, a command
99
+ * or a URL: it runs no hook while it waits.
100
+ */
101
+ private _handleAntigravityOutput;
102
+ /**
103
+ * Follows what Codex is doing through the title it gives to its terminal: Codex only runs the hooks the user
104
+ * trusted, while the terminal of the assistant always receives the title.
105
+ */
106
+ private _handleTitleChange;
107
+ /**
108
+ * Returns the action of the notifications of the assistant, which shows its panel when it is hidden.
109
+ */
110
+ private _getShowToastAction;
111
+ private _ensureMcpServer;
112
+ private _startWatcher;
113
+ private _getEnvironment;
114
+ private _ensureTerminal;
115
+ private _disposeTerminal;
116
+ /**
117
+ * Fits the terminal to its container. A collapsed panel has no size: fitting would give invalid dimensions.
118
+ */
119
+ private _fit;
120
+ private _getTerminalTheme;
121
+ private _handleDragOver;
122
+ /**
123
+ * Types the paths of the dropped assets or files in the prompt of the agent, relative to the project when they
124
+ * are in it, so the user can talk about them.
125
+ */
126
+ private _handleDrop;
127
+ private _handleLocateExecutable;
128
+ private _handleResetExecutableLocation;
129
+ /**
130
+ * Remembers the agent chosen by the user and starts a new session with it. The conversation of the current agent
131
+ * can be resumed later from the menu.
132
+ */
133
+ private _handleAgentChange;
134
+ private _getHeader;
135
+ /**
136
+ * Returns the message welcoming the user each time the panel opens, until they type or close it.
137
+ */
138
+ private _getWelcome;
139
+ private _getPlaceholder;
140
+ private _getNotFoundPlaceholder;
141
+ private _getExitedBar;
142
+ }
@@ -1,6 +1,25 @@
1
1
  import { Component, ReactNode } from "react";
2
2
  import { Editor } from "../main";
3
3
  import { EditorConsoleProgressLogComponent } from "./console/progress-log";
4
+ export type EditorConsoleEntryLevel = "log" | "warn" | "error";
5
+ export interface IEditorConsoleEntry {
6
+ /**
7
+ * Defines the number of the entry, increasing with each message logged.
8
+ */
9
+ id: number;
10
+ /**
11
+ * Defines the level of the message.
12
+ */
13
+ level: EditorConsoleEntryLevel;
14
+ /**
15
+ * Defines the text of the message.
16
+ */
17
+ message: string;
18
+ /**
19
+ * Defines the date the message was logged at, in milliseconds.
20
+ */
21
+ time: number;
22
+ }
4
23
  export interface IEditorConsoleProps {
5
24
  editor: Editor;
6
25
  }
@@ -37,4 +56,18 @@ export declare class EditorConsole extends Component<IEditorConsoleProps, IEdito
37
56
  */
38
57
  progress(message: ReactNode): Promise<EditorConsoleProgressLogComponent>;
39
58
  private _addLog;
59
+ private _nextEntryId;
60
+ private _entries;
61
+ /**
62
+ * Gets the id the next message logged in the console will have. Read it before an operation to get the messages it
63
+ * logs with `getEntriesSince`.
64
+ */
65
+ get nextEntryId(): number;
66
+ /**
67
+ * Returns the messages logged in the console since the given entry id, oldest first.
68
+ * @param id defines the id of the first entry to return.
69
+ */
70
+ getEntriesSince(id: number): IEditorConsoleEntry[];
71
+ private _addEntry;
72
+ private _getConsoleMessageText;
40
73
  }
@@ -11,6 +11,8 @@ export declare class EditorToolbar extends Component<IEditorToolbarProps> {
11
11
  private _spriteCommands;
12
12
  constructor(props: IEditorToolbarProps);
13
13
  render(): ReactNode;
14
+ private _getAssistantButton;
15
+ private _getAssistantTooltip;
14
16
  private _getToolbar;
15
17
  private _handleOpenProject;
16
18
  private _handleOpenVisualStudioCode;
@@ -9,6 +9,7 @@ import { EditorAnimation } from "./layout/animation";
9
9
  import { EditorAssetsBrowser } from "./layout/assets-browser";
10
10
  import { EditorTerminal } from "./layout/terminal";
11
11
  import { EditorMarketplaceBrowser } from "./layout/marketplace";
12
+ import { EditorAssistant } from "./layout/assistant";
12
13
  export interface IEditorLayoutProps {
13
14
  /**
14
15
  * The editor reference.
@@ -55,6 +56,10 @@ export declare class EditorLayout extends Component<IEditorLayoutProps> {
55
56
  * The marketplace browser of the editor.
56
57
  */
57
58
  marketplace: EditorMarketplaceBrowser | null;
59
+ /**
60
+ * The AI assistant docked on the right of the editor.
61
+ */
62
+ assistant: EditorAssistant | null;
58
63
  /**
59
64
  * Observable for when the layout has changed.
60
65
  */
@@ -63,8 +68,13 @@ export declare class EditorLayout extends Component<IEditorLayoutProps> {
63
68
  private _model;
64
69
  private _components;
65
70
  private _layoutVersion;
71
+ private _assistantSize;
72
+ private _assistantLayoutSize;
73
+ private _assistantPanel;
74
+ private _assistantAnimationTimeout;
66
75
  constructor(props: IEditorLayoutProps);
67
76
  render(): ReactNode;
77
+ componentDidUpdate(): void;
68
78
  componentDidCatch(): void;
69
79
  private _layoutFactory;
70
80
  private _saveLayout;
@@ -91,4 +101,16 @@ export declare class EditorLayout extends Component<IEditorLayoutProps> {
91
101
  * @param tabId defines the id of the tab to remove from the layout.
92
102
  */
93
103
  removeLayoutTab(tabId: string): void;
104
+ /**
105
+ * Expands or collapses the panel of the assistant to match the state of the editor. The panel can only be resized
106
+ * once the group computed its first layout: until then, its default size already matches the state.
107
+ * @param animate defines wether or not the panel slides to its new size.
108
+ */
109
+ private _syncAssistantPanel;
110
+ /**
111
+ * Lets the panels slide to their new sizes the next time they change, by enabling the transition of their size for
112
+ * the duration of the animation only: resizing the panels by dragging their handle must follow the pointer.
113
+ */
114
+ private _animateAssistantPanel;
115
+ private _handleSplitLayout;
94
116
  }
@@ -2,6 +2,7 @@ import { Component, ReactNode } from "react";
2
2
  import { EditorProjectCompressedTextureQuality, EditorProjectCompressedTextureSoftware, EditorProjectPackageManager } from "../project/typings";
3
3
  import { CommandPalette } from "./dialogs/command-palette/command-palette";
4
4
  import { EditorLayout } from "./layout";
5
+ import { EditorAssistantWorkState } from "./layout/assistant/hooks";
5
6
  import "./nodes/camera";
6
7
  import "./nodes/scene-link";
7
8
  export declare function createEditor(): void;
@@ -64,6 +65,14 @@ export interface IEditorState {
64
65
  * Defines the list of tabs that are currently opened in the layout.
65
66
  */
66
67
  openedTabs: string[];
68
+ /**
69
+ * Defines wether or not the AI assistant panel is open on the right of the editor.
70
+ */
71
+ assistantOpen: boolean;
72
+ /**
73
+ * Defines what the AI assistant is doing: nothing, working on a request, or waiting for the user to answer it.
74
+ */
75
+ assistantWorkState: EditorAssistantWorkState;
67
76
  /**
68
77
  * Defines if the project is being edited.
69
78
  */
@@ -107,6 +116,16 @@ export declare class Editor extends Component<IEditorProps, IEditorState> {
107
116
  * @param absolutePath defines the absolute path to the project to open.
108
117
  */
109
118
  openProject(absolutePath: string): Promise<void>;
119
+ /**
120
+ * Updates the native menu of the application with the current state of the editor.
121
+ */
122
+ updateMenu(): void;
123
+ /**
124
+ * Shows or hides the AI assistant panel docked on the right of the editor. Hiding it keeps its session running.
125
+ * The AI assistant is an experimental feature: it can't be shown while experimental features are disabled.
126
+ * @param open defines wether or not the AI assistant panel is open.
127
+ */
128
+ setAssistantOpen(open: boolean): void;
110
129
  /**
111
130
  * Closes the current editor window after asking for confirmation.
112
131
  */
@@ -1,4 +1,5 @@
1
1
  export declare function setupEditorMenu(options: {
2
2
  enableExperimentalFeatures: boolean;
3
3
  openedTabs?: string[];
4
+ assistantOpen?: boolean;
4
5
  }): void;
@@ -1,4 +1,4 @@
1
- import { Scene } from "babylonjs";
1
+ import { Observable, Scene } from "babylonjs";
2
2
  import { Editor } from "../editor/main";
3
3
  import { IMCPActionOptions } from "./action";
4
4
  export interface IEditorMCPDataType {
@@ -14,8 +14,52 @@ export declare const MCPServerPort = 3712;
14
14
  * Each handler has the signature `(scene, data, options) => any | Promise<any>`.
15
15
  */
16
16
  export declare const MCPEndpoints: Record<string, (scene: Scene, data: any, options: IMCPActionOptions) => any>;
17
+ export interface IEditorMcpServerOptions {
18
+ /**
19
+ * Defines the port to listen on. 0 lets the system pick a free port.
20
+ * @default MCPServerPort
21
+ */
22
+ port?: number;
23
+ /**
24
+ * Defines the token every request must send in the "x-babylonjs-editor-token" header. Null accepts every request.
25
+ */
26
+ token?: string | null;
27
+ }
28
+ export interface IEditorMcpServer {
29
+ /**
30
+ * Defines the port the server listens on, on the loopback interface.
31
+ */
32
+ readonly port: number;
33
+ /**
34
+ * Defines the token every request must send, if any.
35
+ */
36
+ readonly token: string | null;
37
+ /**
38
+ * Notified with the name of the endpoint each time a tool starts being handled.
39
+ */
40
+ readonly onRequestObservable: Observable<string>;
41
+ /**
42
+ * Notified with the name of the endpoint and wether it succeeded each time a tool was handled.
43
+ */
44
+ readonly onResponseObservable: Observable<{
45
+ endpoint: string;
46
+ succeeded: boolean;
47
+ }>;
48
+ /**
49
+ * Stops listening.
50
+ */
51
+ close(): Promise<void>;
52
+ }
53
+ /**
54
+ * Starts the HTTP server the MCP server of the editor sends the tools it receives to. It only listens on the
55
+ * loopback interface, and rejects every request sent by a web page.
56
+ * @param editor defines the reference to the editor.
57
+ * @param options defines the port to listen on and the token requests must send.
58
+ */
59
+ export declare function startMcpServer(editor: Editor, options?: IEditorMcpServerOptions): Promise<IEditorMcpServer>;
17
60
  /**
18
- * Initializes the editor MCP HTTP server.
61
+ * Initializes the editor MCP HTTP server on its well known port, without any token, for the MCP server of the
62
+ * Claude Desktop extension.
19
63
  * Resilient: if the port is already in use (e.g. a second editor window), the error is caught
20
64
  * and logged in the editor console instead of crashing the application.
21
65
  * @param editor defines the reference to the editor.
@@ -0,0 +1,28 @@
1
+ import { Scene } from "babylonjs";
2
+ import { IMCPActionOptions } from "../action";
3
+ /**
4
+ * Defines the default width, height and depth of a decal, in centimeters, like the decals painted in the editor.
5
+ */
6
+ export declare const defaultDecalSize = 100;
7
+ /**
8
+ * Defines the configuration of a decal saved in the metadata of its mesh. It is the one the decals painted in the
9
+ * editor have, so the inspector edits both the same way.
10
+ */
11
+ export interface IDecalConfiguration {
12
+ angle: number;
13
+ sizeX: number;
14
+ sizeY: number;
15
+ sizeZ: number;
16
+ meshId: string;
17
+ position: number[];
18
+ normal: number[];
19
+ }
20
+ /**
21
+ * Projects a decal (a sticker made of a material: a logo, a crack, a stain, a poster, a road marking...) on a mesh. The
22
+ * decal is parented to the mesh and follows it.
23
+ */
24
+ export declare function createDecal(scene: Scene, data: any, options: IMCPActionOptions): Promise<any>;
25
+ /**
26
+ * Changes the size, the angle or the place of a decal, building its geometry again on the mesh it is projected on.
27
+ */
28
+ export declare function updateDecal(scene: Scene, data: any, options: IMCPActionOptions): any;
@@ -0,0 +1,26 @@
1
+ export interface IKeyDescription {
2
+ /**
3
+ * Defines the value of "KeyboardEvent.key", like "w", " " or "Shift".
4
+ */
5
+ key: string;
6
+ /**
7
+ * Defines the value of "KeyboardEvent.code", like "KeyW", "Space" or "ShiftLeft".
8
+ */
9
+ code: string;
10
+ /**
11
+ * Defines the value of the legacy "KeyboardEvent.keyCode", like 87 for W.
12
+ */
13
+ keyCode: number;
14
+ }
15
+ /**
16
+ * Returns the description of the given key, given as its "KeyboardEvent.key" value ("w", "W", " ", "Shift",
17
+ * "ArrowUp") or its name ("Space", "Ctrl").
18
+ * @param name defines the key.
19
+ */
20
+ export declare function getKeyDescription(name: string): IKeyDescription;
21
+ /**
22
+ * Returns the value stored by the "@visibleAsKeyMap" decorator for the given key: the character code of the upper-cased
23
+ * "KeyboardEvent.key" value, as the inspector of the editor stores it.
24
+ * @param value defines the key: a number is kept as is, a string is a key ("w", "Space").
25
+ */
26
+ export declare function getKeyMapValue(value: unknown): number;
@@ -0,0 +1,29 @@
1
+ import { Scene } from "babylonjs";
2
+ import { IMCPActionOptions } from "../action";
3
+ /**
4
+ * Plays the scene in the preview of the editor, like the Play button: the project is exported, its scripts compiled
5
+ * and the game runs in the preview. Returns what the console received while it started.
6
+ */
7
+ export declare function playScene(_scene: Scene, data: any, options: IMCPActionOptions): Promise<any>;
8
+ /**
9
+ * Stops the game playing in the preview of the editor.
10
+ */
11
+ export declare function stopScene(_scene: Scene, _data: any, options: IMCPActionOptions): any;
12
+ /**
13
+ * Returns the messages logged in the console of the editor.
14
+ */
15
+ export declare function getConsoleLogs(_scene: Scene, data: any, options: IMCPActionOptions): any;
16
+ /**
17
+ * Simulates the input of a player in the game playing in the preview: keys held for a duration, mouse movements and
18
+ * clicks, dispatched on the canvas like the ones of the user.
19
+ */
20
+ export declare function simulateInput(_scene: Scene, data: any, options: IMCPActionOptions): Promise<any>;
21
+ /**
22
+ * Returns the state of the game playing in the preview: the active camera, the playing animation groups and the
23
+ * transform of the given nodes. Compare the states before and after `simulate_input` to check that the game reacts.
24
+ */
25
+ export declare function inspectPlayScene(_scene: Scene, data: any, options: IMCPActionOptions): any;
26
+ /**
27
+ * Returns the scene to take screenshots of: the game when it plays in the preview, the scene of the editor otherwise.
28
+ */
29
+ export declare function getScreenshotScene(scene: Scene, options: IMCPActionOptions): Scene;
@@ -1,9 +1,10 @@
1
1
  import { Scene } from "babylonjs";
2
2
  import { IMCPActionOptions } from "./action";
3
3
  /**
4
- * Takes a screenshot of the preview for visual verification.
4
+ * Takes a screenshot of the preview for visual verification: the game when it plays in the preview (the scene of the
5
+ * editor is not rendered then), the scene of the editor otherwise.
5
6
  */
6
- export declare function getScreenshot(scene: Scene, data: any): Promise<any>;
7
+ export declare function getScreenshot(scene: Scene, data: any, options: IMCPActionOptions): Promise<any>;
7
8
  /**
8
9
  * Frames the editor camera on a node to help screenshots.
9
10
  */
@@ -19,15 +19,15 @@ export declare function writeScript(_scene: Scene, data: any): Promise<any>;
19
19
  /**
20
20
  * Attaches a script file to a node, writing the node script metadata as the inspector does.
21
21
  */
22
- export declare function attachScript(scene: Scene, data: any, options: IMCPActionOptions): any;
22
+ export declare function attachScript(scene: Scene, data: any, options: IMCPActionOptions): Promise<any>;
23
23
  /**
24
24
  * Lists the scripts attached to a node and their exported values.
25
25
  */
26
- export declare function listAttachedScripts(scene: Scene, data: any): any;
26
+ export declare function listAttachedScripts(scene: Scene, data: any): Promise<any>;
27
27
  /**
28
28
  * Sets an exported/inspector value of an attached script on a node.
29
29
  */
30
- export declare function setScriptExportedValue(scene: Scene, data: any, options: IMCPActionOptions): any;
30
+ export declare function setScriptExportedValue(scene: Scene, data: any, options: IMCPActionOptions): Promise<any>;
31
31
  /**
32
32
  * Removes an attached script from a node.
33
33
  */
@@ -0,0 +1,33 @@
1
+ import { Scene } from "babylonjs";
2
+ import { VisibleInInspectorDecoratorObject } from "../../editor/layout/inspector/script/tools";
3
+ /**
4
+ * Defines a property of a script shown in the inspector (a "@visibleAs*" decorated property), with its current value.
5
+ */
6
+ export interface IScriptProperty {
7
+ key: string;
8
+ type: string;
9
+ label?: string;
10
+ description?: string;
11
+ entityType?: string;
12
+ assetType?: string;
13
+ typeRestriction?: string;
14
+ min?: number;
15
+ max?: number;
16
+ value: any;
17
+ }
18
+ /**
19
+ * Compiles the given attached script like the inspector does to find its "@visibleAs*" decorated properties, and
20
+ * updates the values saved in the metadata of the object: the missing ones get their default value, the ones of
21
+ * removed properties are removed. The loader of the game requires these values for scripts with such properties.
22
+ * @param script defines the script attached to an object, from "object.metadata.scripts".
23
+ * @returns the decorated properties of the script.
24
+ */
25
+ export declare function updateScriptValues(script: any): Promise<VisibleInInspectorDecoratorObject[]>;
26
+ /**
27
+ * Returns the decorated properties of the given script with their current values.
28
+ */
29
+ export declare function getScriptProperties(script: any, output: VisibleInInspectorDecoratorObject[]): IScriptProperty[];
30
+ /**
31
+ * Converts the given value to the value saved for the given decorated property, as the inspector saves it.
32
+ */
33
+ export declare function getScriptPropertyValue(scene: Scene, property: VisibleInInspectorDecoratorObject, value: any): Promise<any>;
@@ -0,0 +1,49 @@
1
+ import { IncomingMessage, Server, ServerResponse } from "http";
2
+ /**
3
+ * Defines the name of the HTTP header the MCP server sends the token of the editor in.
4
+ */
5
+ export declare const MCPTokenHeader = "x-babylonjs-editor-token";
6
+ /**
7
+ * Defines the maximum size, in bytes, of the body of a request sent to the editor.
8
+ */
9
+ export declare const MCPMaxRequestBodySize: number;
10
+ export interface IMCPRequestListenerOptions {
11
+ /**
12
+ * Defines the token requests must send in the "x-babylonjs-editor-token" header. Null accepts every request.
13
+ */
14
+ token: string | null;
15
+ /**
16
+ * Returns the function handling the given endpoint, or undefined when the endpoint doesn't exist.
17
+ */
18
+ getAction: (endpoint: string) => ((data: any) => any) | undefined;
19
+ /**
20
+ * Called each time a request for an existing endpoint is about to be handled.
21
+ */
22
+ onRequest?: (endpoint: string) => void;
23
+ /**
24
+ * Called each time a request for an existing endpoint was handled, successfully or not.
25
+ */
26
+ onResponse?: (endpoint: string, succeeded: boolean) => void;
27
+ }
28
+ /**
29
+ * Returns wether or not the given token matches the expected one, in a time that doesn't depend on where they differ.
30
+ * @param received defines the token received with the request.
31
+ * @param expected defines the token of the editor.
32
+ */
33
+ export declare function isMCPTokenValid(received: string | string[] | undefined, expected: string): boolean;
34
+ /**
35
+ * Creates the function handling the requests sent to the editor by its MCP server. Each request is a POST whose
36
+ * JSON body holds the name of the endpoint in "endpoint" and the arguments of the tool.
37
+ * @param options defines the options of the listener.
38
+ */
39
+ export declare function createMCPRequestListener(options: IMCPRequestListenerOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
40
+ /**
41
+ * Starts listening with the given request listener on the loopback interface only.
42
+ * @param listener defines the function handling the requests.
43
+ * @param port defines the port to listen on. 0 lets the system pick a free one.
44
+ * @returns the server and the port it listens on.
45
+ */
46
+ export declare function listenMCPServer(listener: (req: IncomingMessage, res: ServerResponse) => Promise<void>, port: number): Promise<{
47
+ server: Server;
48
+ port: number;
49
+ }>;
@@ -59,6 +59,7 @@ export declare function toVector3(value: any): Vector3;
59
59
  /**
60
60
  * Deeply sets a property on the given target using a dotted path (e.g. "material.albedoColor").
61
61
  * Arrays are coerced to Color3/Vector3/Color4/Vector2/Vector4 based on the existing property type.
62
+ * Methods are never replaced: "isEnabled" is set through "setEnabled", and other methods throw.
62
63
  * @param target defines the root object on which to set the property.
63
64
  * @param path defines the dotted path to the property to set.
64
65
  * @param value defines the value to set.