载入中...
搜索中...
未找到
EditorAutomationProvider.cpp
浏览该文件的文档.
140std::string EditorAutomationProvider::invoke(const std::string& operation, const std::string& requestJson) {
144 return errorJson(EditorStatus::Rejected, "editor.automation.invalid-json", "Request must be a JSON object");
177 if (const auto* value = integerField(request, "expectedRevision")) expected = static_cast<Revision>(*value);
186 auto result = session_.executeRetainedPlan(PlanId(stringField(request, "planId")), CommandSource::Automation);
194 auto planned = session_.planCommand(command, valueField(request, "payload"), CommandSource::Automation);
220 const bool changed = operation == "undo" ? session_.transactions().undo() : session_.transactions().redo();
234 const auto* descriptor = descriptorValue ? descriptorValue->getIf<EditorValue::Object>() : nullptr;
260std::string EditorAutomationProvider::describeObservation(const EditorValue::Object& request) const {
264 return errorJson(EditorStatus::NotFound, "editor.automation.observe-session", "Observation session not found");
274 return errorJson(EditorStatus::NotFound, "editor.automation.observe-session", "Observation session not found");
277 return errorJson(EditorStatus::Rejected, "editor.automation.observe-event", "Observation event must be an object");
286 return errorJson(EditorStatus::NotFound, "editor.automation.observe-session", "Observation session not found");
304 return errorJson(EditorStatus::NotFound, "editor.automation.observe-session", "Observation session not found");
315 if (!value) return errorJson(EditorStatus::Failed, "editor.automation.target-list", "Could not build response");
336 eve::cap::forEach<editing::IEditorPackageProvider>([&](editing::IEditorPackageProvider* provider) {
345 eve::cap::forEach<IEditorAutomationTargetFactory>([&](IEditorAutomationTargetFactory* factory) {
374 return errorJson(EditorStatus::Rejected, "editor.automation.target-id", "Target id must not be empty");
376 return errorJson(EditorStatus::Conflict, "editor.automation.target-exists", "Target already exists");
377 if (editorMcpProjector().isAttached() && !editorMcpProjector().mountedTargetTypes().contains(type))
398 if (!registered.ok()) return editorValueToJson(resultValue(registered.code(), registered.diagnostics()));
const T & value() const &
Borrow the value from a const lvalue after checking success.
Definition Result.h:339
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:286
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
const std::string & value() const noexcept
Returns the exact legacy or canonical compatibility spelling.
Definition Identity.h:365
Deterministic owning value tree shared by authoring hosts.
Definition EditingValue.h:23
void detachHost()
Clear the Host-scoped MCP projection filter.
Definition EditorAutomationProvider.cpp:426
~EditorAutomationProvider() override
Releases EditorAutomationProvider resources.
EditorAutomationProvider(EditorCommandService &commands, EditorTargetCoordinator &targets)
Bind borrowed services that outlive this provider.
Definition EditorAutomationProvider.cpp:125
void targetUnregistered(const TargetId &target)
Clear automation state that still borrows an unregistered target.
Definition EditorAutomationProvider.cpp:134
std::string invoke(const std::string &operation, const std::string &requestJson) override
Invoke discovery, inspect, execute, plan, commit, undo or redo.
Definition EditorAutomationProvider.cpp:140
Result< void > attachHost(EditorHost *host)
Attach a borrowed EditorHost as the MCP projection scope (Mode A). @ownership Borrowed; host must out...
Definition EditorAutomationProvider.cpp:422
Registry and execution gate for UI-, script- and automation-neutral commands.
Definition EditorCommandService.h:60
bool supportsPlanning(const CommandId &id) const
Return whether the registered command requires plan/commit execution.
Definition EditorAssetDatabase.cpp:327
Composition runtime that discovers EditorPackage providers and installs them.
Definition EditorHost.h:53
Result< EditorValue > auditCompleteness() const
Audit incomplete packages and orphan automation factories.
Definition EditorMcpProjector.cpp:43
std::unordered_set< std::string > mountedOwners() const
Mounted owner allowlist, empty when detached (no filter). @cost Linear in mounted package count; retu...
Definition EditorMcpProjector.cpp:29
Result< void > attach(EditorHost *host, EditorMcpExportMode mode=EditorMcpExportMode::Commands)
Attach a borrowed host as the active MCP projection scope.
Definition EditorMcpProjector.cpp:18
std::unordered_set< std::string > mountedTargetTypes() const
Mounted target type allowlist, empty when detached (no filter). @cost Linear in mounted target types;...
Definition EditorMcpProjector.cpp:36
void clearTarget()
Clear the active target and invalidate retained plans derived from it.
Definition EditorPropertyPresenter.cpp:326
void setCommandService(EditorCommandService *service)
Compatibility-only nullable pointer facade over bindCommandService() and clearCommandService().
Definition EditorSession.h:110
Result< void > cancelRetainedPlan(const PlanId &id)
Discard one retained plan without executing it.
Definition EditorPropertyPresenter.cpp:493
Result< TransactionReceipt > executeCommandReceipt(const CommandId &id, const EditorValue &payload={}, CommandSource source=CommandSource::Api)
Execute a legacy-compatible command and return a V2 transaction receipt.
Definition EditorPropertyPresenter.cpp:448
void setSessionId(SessionId id)
Assign the stable identity included in asynchronous context snapshots.
Definition EditorSession.h:118
void clearRetainedPlans()
Discard all retained plans, for example after replacing a document or target.
Definition EditorPropertyPresenter.cpp:503
Result< CommandPlan > planCommand(const CommandId &id, const EditorValue &payload={}, CommandSource source=CommandSource::Api, std::optional< Revision > expectedRevision=std::nullopt) const
Plan a registered command without applying target mutations.
Definition EditorPropertyPresenter.cpp:415
void setHostProfile(HostProfile profile)
Set the host capability boundary used for command discovery and execution.
Definition EditorSession.h:114
Result< TransactionReceipt > executeRetainedPlan(const PlanId &id, CommandSource source=CommandSource::Api)
Execute a retained plan. Successful plans are consumed exactly once.
Definition EditorPropertyPresenter.cpp:482
const TargetId & boundTargetId() const noexcept
Return the identity of the current binding without dereferencing the target.
Definition EditorSession.h:95
Result< TransactionReceipt > executePlan(const CommandPlan &plan, const EditorValue &payload={}, CommandSource source=CommandSource::Api)
Execute a previously returned plan through its registered executor.
Definition EditorPropertyPresenter.cpp:430
Result< PlanId > retainPlan(const CommandId &id, const EditorValue &payload={}, CommandSource source=CommandSource::Api, std::optional< Revision > expectedRevision=std::nullopt)
Plan a command and retain its immutable payload under the returned plan id.
Definition EditorPropertyPresenter.cpp:470
Coordinates editable targets, per-target histories and domain commands.
Definition EditorTargetCoordinator.h:26
Result< TransactionReceipt > redo(const TargetId &target)
Redo.
Definition EditorTargetCoordinator.cpp:251
Result< void > unregisterTarget(const TargetId &target)
Unregisters target.
Definition EditorTargetCoordinator.cpp:205
Result< EditorValue > inspect(const TargetId &target) const
Inspect.
Definition EditorTargetCoordinator.cpp:231
Result< void > bind(EditorSession &session, const TargetId &target)
Binds .
Definition EditorTargetCoordinator.cpp:219
Result< TransactionReceipt > undo(const TargetId &target)
Undo.
Definition EditorTargetCoordinator.cpp:243
Result< void > registerTarget(IEditableTarget &target)
Registers target.
Definition EditorTargetCoordinator.cpp:163
bool undo()
Compatibility-only boolean projection of undoTransaction().
Definition EditorSimulationPreview.cpp:311
bool redo()
Compatibility-only boolean projection of redoTransaction().
Definition EditorSimulationPreview.cpp:315
Upper capability boundary for one editor host.
Definition EditorHostProfile.h:51
static HostProfile automation()
Headless profile that denies commands unless allow-listed.
Definition EditorHostProfile.cpp:33
Multicast push-based stream: both an Observable and a push source. Thread-safe: onNext/onError/onComp...
Definition Rx.h:418
RAII-style dispose handle for an active stream subscription. Disposing unsubscribes from the source; ...
Definition Rx.h:93
constexpr eve::DiagnosticCode diagnosticCodeForStatus(Status status) noexcept
Coarse default diagnostic category for a failure status.
Definition EditingResult.h:109
std::string editorValueToJson(const EditorValue &value)
Serialize an EditorValue to deterministic compact JSON.
Definition EditingValueJson.cpp:346
Result< EditorValue > editorValueFromJson(const std::string &json)
Parse JSON into the pointer-free EditorValue protocol tree.
Definition EditingValueJson.cpp:352
Result< Value > propertySchemaToJsonSchema(const PropertySchema &schema, std::string_view schemaId)
Project a PropertySchema into a JSON Schema object tree (pointer-free Value).
Definition PropertySchemaJson.cpp:65
Diagnostic ruleDiagnostic(eve::DiagnosticCode code, RuleId rule, DiagnosticSeverity severity, std::string message)
Build an owning common diagnostic carrying an open editing rule identity.
Definition EditingResult.cpp:20
RuleId diagnosticRule(const Diagnostic &diagnostic)
Return the projected editing rule, or an empty RuleId when absent.
Definition EditingResult.h:38
Definition ActionPreviewController.cpp:6
EditorMcpProjector & editorMcpProjector()
Process-wide projector used by EditorAutomationProvider and eve.mcp.attachEditor.
Definition EditorMcpProjector.cpp:13
eve::editing::Value EditorValue
Compatibility alias for the UI-independent authoring value tree.
Definition EditorValue.h:8
eve::editing::TransactionState TransactionState
Definition EditorProtocol.h:15
@ Commands
Mode A: keep eve_editor_* with schema enrichment (default).
std::string_view statusName(BattleStatus status) noexcept
Return the stable protocol spelling of a battle status.
Definition TacticsTypes.cpp:216
Presentation and execution metadata for a registered command.
Definition EditorCommandService.h:30
Definition EditorAutomationProvider.cpp:117
EditorValue::Object descriptor
Definition EditorAutomationProvider.cpp:118
rx::Subscription subscription
Definition EditorAutomationProvider.cpp:121
std::unique_ptr< rx::Observable< std::string > > distinct
Definition EditorAutomationProvider.cpp:120
rx::Subject< std::string > source
Definition EditorAutomationProvider.cpp:119
std::vector< std::string > pending
Definition EditorAutomationProvider.cpp:122