载入中...
搜索中...
未找到
EditorAutomationProvider.cpp
浏览该文件的文档.
2
3#include "common/Capability.h"
7#include "editor/EditorHost.h"
11#include "rx/Rx.h"
12
13#include <algorithm>
14#include <cstdint>
15#include <optional>
16#include <string>
17#include <unordered_map>
18#include <utility>
19#include <vector>
20
21namespace eve::editor {
22
23namespace {
24
25const char* statusName(EditorStatus status) {
26 switch (status) {
27 case EditorStatus::Ok: return "ok";
28 case EditorStatus::Applied: return "applied";
29 case EditorStatus::Pending: return "pending";
30 case EditorStatus::NoOp: return "no-op";
31 case EditorStatus::Rejected: return "rejected";
32 case EditorStatus::Conflict: return "conflict";
33 case EditorStatus::NotFound: return "not-found";
34 case EditorStatus::Unsupported: return "unsupported";
35 case EditorStatus::Cancelled: return "cancelled";
36 case EditorStatus::Failed: return "failed";
37 }
38 return "failed";
39}
40
41const char* transactionStateName(TransactionState state) {
42 switch (state) {
43 case TransactionState::Planning: return "planning";
44 case TransactionState::Previewing: return "previewing";
45 case TransactionState::PendingAuthority: return "pending-authority";
46 case TransactionState::Committed: return "committed";
47 case TransactionState::RolledBack: return "rolled-back";
48 case TransactionState::Rejected: return "rejected";
49 case TransactionState::Conflicted: return "conflicted";
50 case TransactionState::Failed: return "failed";
51 }
52 return "failed";
53}
54
55EditorValue diagnosticsValue(const std::vector<EditorDiagnostic>& diagnostics) {
57 for (const EditorDiagnostic& diagnostic : diagnostics) {
59 value["rule"] = editing::diagnosticRule(diagnostic).value();
60 value["severity"] = static_cast<std::int64_t>(diagnostic.severity());
61 value["message"] = diagnostic.message();
62 values.emplace_back(std::move(value));
63 }
64 return EditorValue(std::move(values));
65}
66
67EditorValue resultValue(EditorStatus status, const std::vector<EditorDiagnostic>& diagnostics) {
69 result["status"] = statusName(status);
70 result["accepted"] = status == EditorStatus::Applied || status == EditorStatus::Pending ||
71 status == EditorStatus::NoOp;
72 result["diagnostics"] = diagnosticsValue(diagnostics);
73 return EditorValue(std::move(result));
74}
75
76EditorValue receiptValue(const Result<TransactionReceipt>& result) {
77 EditorValue response = resultValue(result.code(), result.diagnostics());
78 if (result.ok()) {
79 auto* object = response.getIf<EditorValue::Object>();
80 (*object)["transactionId"] = result.value().id.value();
81 (*object)["state"] = transactionStateName(result.value().state);
82 (*object)["beforeRevision"] = static_cast<std::int64_t>(result.value().beforeRevision);
83 (*object)["afterRevision"] = static_cast<std::int64_t>(result.value().afterRevision);
84 }
85 return response;
86}
87
88const EditorValue* findField(const EditorValue::Object& request, const char* key) {
89 const auto found = request.find(key);
90 return found == request.end() ? nullptr : &found->second;
91}
92
93std::string stringField(const EditorValue::Object& request, const char* key) {
94 const EditorValue* value = findField(request, key);
95 const auto* text = value ? value->getIf<std::string>() : nullptr;
96 return text ? *text : std::string{};
97}
98
99const std::int64_t* integerField(const EditorValue::Object& request, const char* key) {
100 const EditorValue* value = findField(request, key);
101 return value ? value->getIf<std::int64_t>() : nullptr;
102}
103
104EditorValue valueField(const EditorValue::Object& request, const char* key) {
105 const EditorValue* value = findField(request, key);
106 return value ? *value : EditorValue{};
107}
108
109std::string errorJson(EditorStatus status, const char* rule, std::string message) {
110 return editorValueToJson(resultValue(
112 DiagnosticSeverity::Error, std::move(message))}));
113}
114
115} // namespace
116
124
131
133
135 if (session_.boundTargetId() != target) return;
136 session_.clearRetainedPlans();
137 session_.clearTarget();
138}
139
140std::string EditorAutomationProvider::invoke(const std::string& operation, const std::string& requestJson) {
141 refreshProfile();
142 Result<EditorValue> parsed = editorValueFromJson(requestJson.empty() ? "{}" : requestJson);
143 if (!parsed.ok() || parsed.value().type() != EditorValue::Type::Object)
144 return errorJson(EditorStatus::Rejected, "editor.automation.invalid-json", "Request must be a JSON object");
145 const auto& request = *parsed.value().getIf<EditorValue::Object>();
146 if (operation == "commands") return commandsJson();
147 if (operation == "target-list") return targetList();
148 if (operation == "package-audit") {
149 auto audit = editorMcpProjector().auditCompleteness();
150 lastDiagnostics_ = audit.diagnostics();
151 if (!audit.ok()) return editorValueToJson(resultValue(audit.code(), audit.diagnostics()));
152 EditorValue response = resultValue(EditorStatus::Applied, {});
153 (*response.getIf<EditorValue::Object>())["audit"] = std::move(audit).takeValue();
154 return editorValueToJson(response);
155 }
156 if (operation == "target-create") return createTarget(request);
157 if (operation == "target-close") return closeTarget(request);
158 if (operation == "observe-start") return startObservation(request);
159 if (operation == "observe-describe") return describeObservation(request);
160 if (operation == "observe-publish") return publishObservation(request);
161 if (operation == "observe-poll") return pollObservation(request);
162 if (operation == "observe-close") return closeObservation(request);
163 if (operation == "inspect") {
164 auto result = targets_->inspect(TargetId(stringField(request, "target")));
165 lastDiagnostics_ = result.diagnostics();
166 EditorValue response = resultValue(result.code(), result.diagnostics());
167 if (result.ok()) (*response.getIf<EditorValue::Object>())["target"] = result.value();
168 return editorValueToJson(response);
169 }
170 if (operation == "plan" || operation == "execute") {
171 auto bound = bindRequestedTarget(request);
172 if (!bound.ok()) return editorValueToJson(resultValue(bound.code(), bound.diagnostics()));
173 }
174 if (operation == "plan") {
175 const std::string command = stringField(request, "command");
176 std::optional<Revision> expected;
177 if (const auto* value = integerField(request, "expectedRevision")) expected = static_cast<Revision>(*value);
178 auto result = session_.retainPlan(CommandId(command), valueField(request, "payload"),
179 CommandSource::Automation, expected);
180 lastDiagnostics_ = result.diagnostics();
181 EditorValue response = resultValue(result.code(), result.diagnostics());
182 if (result.ok()) (*response.getIf<EditorValue::Object>())["planId"] = result.value().value();
183 return editorValueToJson(response);
184 }
185 if (operation == "commit") {
186 auto result = session_.executeRetainedPlan(PlanId(stringField(request, "planId")), CommandSource::Automation);
187 lastDiagnostics_ = result.diagnostics();
188 return editorValueToJson(receiptValue(result));
189 }
190 if (operation == "execute") {
191 const CommandId command(stringField(request, "command"));
192 std::optional<Result<TransactionReceipt>> result;
193 if (commands_->supportsPlanning(command)) {
194 auto planned = session_.planCommand(command, valueField(request, "payload"), CommandSource::Automation);
195 if (!planned.ok()) {
196 result.emplace(Result<TransactionReceipt>::failure(planned.status()));
197 } else {
198 result.emplace(session_.executePlan(planned.value(), valueField(request, "payload"),
199 CommandSource::Automation));
200 }
201 } else {
202 result.emplace(session_.executeCommandReceipt(command, valueField(request, "payload"),
203 CommandSource::Automation));
204 }
205 lastDiagnostics_ = result->diagnostics();
206 return editorValueToJson(receiptValue(*result));
207 }
208 if (operation == "cancel") {
209 auto result = session_.cancelRetainedPlan(PlanId(stringField(request, "planId")));
210 lastDiagnostics_ = result.diagnostics();
211 return editorValueToJson(resultValue(result.code(), result.diagnostics()));
212 }
213 if (operation == "undo" || operation == "redo") {
214 const TargetId target(stringField(request, "target"));
215 if (!target.empty()) {
216 auto result = operation == "undo" ? targets_->undo(target) : targets_->redo(target);
217 lastDiagnostics_ = result.diagnostics();
218 return editorValueToJson(receiptValue(result));
219 }
220 const bool changed = operation == "undo" ? session_.transactions().undo() : session_.transactions().redo();
221 EditorValue response = resultValue(changed ? EditorStatus::Applied : EditorStatus::NoOp, {});
222 (*response.getIf<EditorValue::Object>())["changed"] = changed;
223 return editorValueToJson(response);
224 }
225 if (operation == "diagnostics")
226 return editorValueToJson(resultValue(EditorStatus::Applied, lastDiagnostics_));
227 return errorJson(EditorStatus::Unsupported, "editor.automation.unsupported-operation",
228 "Unsupported editor automation operation: " + operation);
229}
230
231std::string EditorAutomationProvider::startObservation(const EditorValue::Object& request) {
232 const EditorValue* descriptorValue = findField(request, "descriptor");
233 const EditorValue* eventValue = findField(request, "event");
234 const auto* descriptor = descriptorValue ? descriptorValue->getIf<EditorValue::Object>() : nullptr;
235 const auto* event = eventValue ? eventValue->getIf<EditorValue::Object>() : nullptr;
236 if (!descriptor || !event)
237 return errorJson(EditorStatus::Rejected, "editor.automation.observe-start",
238 "Observation descriptor and initial event must be JSON objects");
239
240 const std::string id = "editor.observe." + std::to_string(nextObservationSession_++);
241 auto session = std::make_unique<ObservationSession>();
242 session->descriptor = *descriptor;
243 session->distinct.reset(session->source.distinctUntilChanged());
244 ObservationSession* observed = session.get();
245 session->subscription = session->distinct->subscribe(
246 [observed](const std::string& value) { observed->pending.push_back(value); });
247 session->source.onNext(editorValueToJson(*eventValue));
248 // startObservation returns the initial event directly. Retain it only as
249 // the distinct baseline so the first poll does not deliver it twice.
250 session->pending.clear();
251 observationSessions_.emplace(id, std::move(session));
252
253 EditorValue response = resultValue(EditorStatus::Applied, {});
254 auto* object = response.getIf<EditorValue::Object>();
255 (*object)["sessionId"] = id;
256 (*object)["event"] = *eventValue;
257 return editorValueToJson(response);
258}
259
260std::string EditorAutomationProvider::describeObservation(const EditorValue::Object& request) const {
261 const std::string id = stringField(request, "sessionId");
262 const auto found = observationSessions_.find(id);
263 if (found == observationSessions_.end())
264 return errorJson(EditorStatus::NotFound, "editor.automation.observe-session", "Observation session not found");
265 EditorValue response = resultValue(EditorStatus::Applied, {});
266 (*response.getIf<EditorValue::Object>())["descriptor"] = found->second->descriptor;
268}
269
270std::string EditorAutomationProvider::publishObservation(const EditorValue::Object& request) {
271 const std::string id = stringField(request, "sessionId");
272 const auto found = observationSessions_.find(id);
273 if (found == observationSessions_.end())
274 return errorJson(EditorStatus::NotFound, "editor.automation.observe-session", "Observation session not found");
275 const EditorValue* event = findField(request, "event");
276 if (!event || event->type() != EditorValue::Type::Object)
277 return errorJson(EditorStatus::Rejected, "editor.automation.observe-event", "Observation event must be an object");
278 found->second->source.onNext(editorValueToJson(*event));
279 return editorValueToJson(resultValue(EditorStatus::Applied, {}));
280}
281
282std::string EditorAutomationProvider::pollObservation(const EditorValue::Object& request) {
283 const std::string id = stringField(request, "sessionId");
284 const auto found = observationSessions_.find(id);
285 if (found == observationSessions_.end())
286 return errorJson(EditorStatus::NotFound, "editor.automation.observe-session", "Observation session not found");
288 for (const std::string& encoded : found->second->pending) {
289 Result<EditorValue> parsed = editorValueFromJson(encoded);
290 if (parsed.ok()) events.push_back(std::move(parsed).takeValue());
291 }
292 found->second->pending.clear();
293 EditorValue response = resultValue(EditorStatus::Applied, {});
294 auto* object = response.getIf<EditorValue::Object>();
295 (*object)["sessionId"] = id;
296 (*object)["events"] = std::move(events);
298}
299
300std::string EditorAutomationProvider::closeObservation(const EditorValue::Object& request) {
301 const std::string id = stringField(request, "sessionId");
302 const auto found = observationSessions_.find(id);
303 if (found == observationSessions_.end())
304 return errorJson(EditorStatus::NotFound, "editor.automation.observe-session", "Observation session not found");
305 found->second->subscription.dispose();
306 observationSessions_.erase(found);
307 EditorValue response = resultValue(EditorStatus::Applied, {});
308 (*response.getIf<EditorValue::Object>())["sessionId"] = id;
310}
311
312std::string EditorAutomationProvider::targetList() const {
313 EditorValue response = resultValue(EditorStatus::Applied, {});
315 if (!value) return errorJson(EditorStatus::Failed, "editor.automation.target-list", "Could not build response");
316
317 const TargetId bound = session_.boundTargetId();
319 for (const auto& summary : targets_->targets()) {
321 item["id"] = summary.id;
322 item["bound"] = summary.id == bound.value();
323 item["owned"] = ownedTargets_.contains(TargetId(summary.id));
324 item["revision"] = static_cast<std::int64_t>(summary.revision);
325 item["generation"] = static_cast<std::int64_t>(summary.generation);
326 if (!summary.type.empty()) item["type"] = summary.type;
327 entries.emplace_back(std::move(item));
328 }
329 (*value)["targets"] = std::move(entries);
330 if (!bound.empty()) (*value)["boundTarget"] = bound.value();
331
332 // Type discovery: the accepted names come from the loaded factories, so the
333 // advertised list cannot drift from what create actually accepts. createSchema
334 // is projected from IEditorPackageProvider when the domain advertises one.
335 std::unordered_map<std::string, editing::PropertySchema> createSchemas;
336 eve::cap::forEach<editing::IEditorPackageProvider>([&](editing::IEditorPackageProvider* provider) {
337 if (!provider) return;
338 for (const editing::EditorTargetTypeSpec& target : provider->package().targetTypes)
339 createSchemas.emplace(target.type, target.createSchema);
340 });
341
342 const auto allowed = editorMcpProjector().mountedTargetTypes();
343 const bool filter = editorMcpProjector().isAttached();
344 std::vector<std::string> types;
345 eve::cap::forEach<IEditorAutomationTargetFactory>([&](IEditorAutomationTargetFactory* factory) {
346 if (!factory) return;
347 for (const std::string_view type : factory->types()) {
348 if (filter && !allowed.contains(std::string(type))) continue;
349 types.emplace_back(type);
350 }
351 });
352 std::sort(types.begin(), types.end());
353 types.erase(std::unique(types.begin(), types.end()), types.end());
354 EditorValue::Array advertised;
355 advertised.reserve(types.size());
356 for (const std::string& type : types) {
358 item["type"] = type;
359 if (const auto found = createSchemas.find(type); found != createSchemas.end()) {
360 auto schema = editing::propertySchemaToJsonSchema(found->second, type);
361 if (schema.ok()) item["createSchema"] = std::move(schema).takeValue();
362 }
363 advertised.emplace_back(std::move(item));
364 }
365 (*value)["supportedTypes"] = std::move(advertised);
366
368}
369
370std::string EditorAutomationProvider::createTarget(const EditorValue::Object& request) {
371 const TargetId target(stringField(request, "target"));
372 const std::string type = stringField(request, "type");
373 if (target.empty())
374 return errorJson(EditorStatus::Rejected, "editor.automation.target-id", "Target id must not be empty");
375 if (ownedTargets_.contains(target))
376 return errorJson(EditorStatus::Conflict, "editor.automation.target-exists", "Target already exists");
377 if (editorMcpProjector().isAttached() && !editorMcpProjector().mountedTargetTypes().contains(type))
378 return errorJson(EditorStatus::Unsupported, "editor.automation.target-type-unmounted",
379 "Attached EditorHost does not mount target type: " + type);
380
381 std::optional<Result<AutomationOwnedTarget>> created;
382 const bool handled = eve::cap::forEachUntil<IEditorAutomationTargetFactory>(
383 [&](IEditorAutomationTargetFactory* factory) {
384 if (!factory->supports(type)) return false;
385 created.emplace(factory->create(target, type, request));
386 return true;
387 });
388 if (!handled) {
389 return errorJson(EditorStatus::Unsupported, "editor.automation.target-type",
390 "No loaded editor adapter supports target type: " + type);
391 }
392 lastDiagnostics_ = created->diagnostics();
393 if (!created->ok() || !created->value().target)
394 return editorValueToJson(resultValue(created->code(), created->diagnostics()));
395
396 auto registered = targets_->registerTarget(*created->value().target);
397 lastDiagnostics_ = registered.diagnostics();
398 if (!registered.ok()) return editorValueToJson(resultValue(registered.code(), registered.diagnostics()));
399 ownedTargets_.emplace(target, std::move(*created).takeValue());
400 EditorValue response = resultValue(EditorStatus::Applied, {});
402 (*value)["target"] = target.value();
403 (*value)["type"] = type;
405}
406
407std::string EditorAutomationProvider::closeTarget(const EditorValue::Object& request) {
408 const TargetId target(stringField(request, "target"));
409 auto found = ownedTargets_.find(target);
410 if (found == ownedTargets_.end())
411 return errorJson(EditorStatus::NotFound, "editor.automation.target-not-found",
412 "Owned automation target does not exist");
413 auto unregistered = targets_->unregisterTarget(target);
414 lastDiagnostics_ = unregistered.diagnostics();
415 if (!unregistered.ok())
416 return editorValueToJson(resultValue(unregistered.code(), unregistered.diagnostics()));
418 ownedTargets_.erase(found);
419 return editorValueToJson(resultValue(EditorStatus::Applied, {}));
420}
421
425
427
428void EditorAutomationProvider::refreshProfile() {
430 const auto owners = editorMcpProjector().mountedOwners();
431 const bool filter = editorMcpProjector().isAttached();
432 if (commands_)
433 for (const CommandDescriptor& command : commands_->commands(HostProfile::developer())) {
434 if (!command.automationAllowed || !profile.hasFeatures(command.requiredFeatures)) continue;
435 if (filter && !owners.contains(command.ownerModule)) continue;
436 profile.allowCommand(command.id);
437 }
438 session_.setHostProfile(std::move(profile));
439}
440
441std::string EditorAutomationProvider::commandsJson() {
442 EditorValue::Array descriptors;
443 const auto owners = editorMcpProjector().mountedOwners();
444 const bool filter = editorMcpProjector().isAttached();
445 for (const CommandDescriptor& command : session_.availableCommands()) {
446 if (filter && !owners.contains(command.ownerModule)) continue;
448 descriptor["id"] = command.id.value();
449 descriptor["displayName"] = command.displayName;
450 descriptor["category"] = command.category;
451 descriptor["owner"] = command.ownerModule;
452 descriptor["planned"] = commands_->supportsPlanning(command.id);
453 if (!command.panelCapability.empty()) descriptor["panelCapability"] = command.panelCapability;
454 if (!command.panelContext.empty()) descriptor["panelContext"] = command.panelContext;
455 if (!command.targetKinds.empty()) {
456 EditorValue::Array kinds;
457 for (const std::string& kind : command.targetKinds) kinds.emplace_back(kind);
458 descriptor["targetKinds"] = std::move(kinds);
459 }
460 auto schema = editing::propertySchemaToJsonSchema(command.payloadSchema, command.id.value());
461 if (schema.ok()) descriptor["inputSchema"] = std::move(schema).takeValue();
462 descriptors.emplace_back(std::move(descriptor));
463 }
464 EditorValue response = resultValue(EditorStatus::Applied, {});
465 (*response.getIf<EditorValue::Object>())["commands"] = EditorValue(std::move(descriptors));
467}
468
469Result<void> EditorAutomationProvider::bindRequestedTarget(const EditorValue::Object& request) {
470 const std::string target = stringField(request, "target");
471 if (target.empty()) return eve::editing::applied<void>();
472 return targets_->bind(session_, TargetId(target));
473}
474
475} // namespace eve::editor
LogicalId target
ActionParameterOperation operation
std::string descriptor
std::vector< QuestEvent > pending
std::unordered_map< std::string, QuestRuntime > entries
bool changed
SQObjectPtr key
Definition ECS.cpp:155
std::vector< FieldTarget > targets
std::string message
const GltfImportRequest & request
wgpu::PopErrorScopeStatus status
std::int32_t second
std::string id
std::string response
Poco::JSON::Object::Ptr result
std::vector< particles::ParticleRecordEvent > events
std::set< std::string > values
Object::Ptr value
bool found
int created
std::string filter
std::string text
std::string kind
std::optional< InteractionSession > session
Definition Tactics.cpp:39
UIHostHandle host
std::vector< VegetationPresetCommand > commands
Move-only operation result carrying either a value or Status.
Definition Result.h:176
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.
std::vector< Value > Array
std::map< std::string, Value > Object
const T * getIf() const
Return an immediately borrowed typed value.
void detachHost()
Clear the Host-scoped MCP projection filter.
~EditorAutomationProvider() override
Releases EditorAutomationProvider resources.
EditorAutomationProvider(EditorCommandService &commands, EditorTargetCoordinator &targets)
Bind borrowed services that outlive this provider.
void targetUnregistered(const TargetId &target)
Clear automation state that still borrows an unregistered target.
std::string invoke(const std::string &operation, const std::string &requestJson) override
Invoke discovery, inspect, execute, plan, commit, undo or redo.
Result< void > attachHost(EditorHost *host)
Attach a borrowed EditorHost as the MCP projection scope (Mode A). @ownership Borrowed; host must out...
Registry and execution gate for UI-, script- and automation-neutral commands.
bool supportsPlanning(const CommandId &id) const
Return whether the registered command requires plan/commit execution.
Composition runtime that discovers EditorPackage providers and installs them.
Definition EditorHost.h:53
Result< EditorValue > auditCompleteness() const
Audit incomplete packages and orphan automation factories.
void detach()
Clear the active attachment.
std::unordered_set< std::string > mountedOwners() const
Mounted owner allowlist, empty when detached (no filter). @cost Linear in mounted package count; retu...
Result< void > attach(EditorHost *host, EditorMcpExportMode mode=EditorMcpExportMode::Commands)
Attach a borrowed host as the active MCP projection scope.
std::unordered_set< std::string > mountedTargetTypes() const
Mounted target type allowlist, empty when detached (no filter). @cost Linear in mounted target types;...
bool isAttached() const
True when a host is attached.
void clearTarget()
Clear the active target and invalidate retained plans derived from it.
void setCommandService(EditorCommandService *service)
Compatibility-only nullable pointer facade over bindCommandService() and clearCommandService().
EditorTransactions & transactions()
Transactions.
Result< void > cancelRetainedPlan(const PlanId &id)
Discard one retained plan without executing it.
Result< TransactionReceipt > executeCommandReceipt(const CommandId &id, const EditorValue &payload={}, CommandSource source=CommandSource::Api)
Execute a legacy-compatible command and return a V2 transaction receipt.
void setSessionId(SessionId id)
Assign the stable identity included in asynchronous context snapshots.
void clearRetainedPlans()
Discard all retained plans, for example after replacing a document or target.
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.
void setHostProfile(HostProfile profile)
Set the host capability boundary used for command discovery and execution.
Result< TransactionReceipt > executeRetainedPlan(const PlanId &id, CommandSource source=CommandSource::Api)
Execute a retained plan. Successful plans are consumed exactly once.
const TargetId & boundTargetId() const noexcept
Return the identity of the current binding without dereferencing the target.
Result< TransactionReceipt > executePlan(const CommandPlan &plan, const EditorValue &payload={}, CommandSource source=CommandSource::Api)
Execute a previously returned plan through its registered executor.
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.
Coordinates editable targets, per-target histories and domain commands.
Result< TransactionReceipt > redo(const TargetId &target)
Redo.
Result< void > unregisterTarget(const TargetId &target)
Unregisters target.
Result< EditorValue > inspect(const TargetId &target) const
Inspect.
Result< void > bind(EditorSession &session, const TargetId &target)
Binds .
Result< TransactionReceipt > undo(const TargetId &target)
Undo.
Result< void > registerTarget(IEditableTarget &target)
Registers target.
bool undo()
Compatibility-only boolean projection of undoTransaction().
bool redo()
Compatibility-only boolean projection of redoTransaction().
Upper capability boundary for one editor host.
bool hasFeatures(HostFeature required) const
True when features.
void allowCommand(CommandId id)
Allow command.
static HostProfile automation()
Headless profile that denies commands unless allow-listed.
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.
std::string editorValueToJson(const EditorValue &value)
Serialize an EditorValue to deterministic compact JSON.
Result< EditorValue > editorValueFromJson(const std::string &json)
Parse JSON into the pointer-free EditorValue protocol tree.
Result< Value > propertySchemaToJsonSchema(const PropertySchema &schema, std::string_view schemaId)
Project a PropertySchema into a JSON Schema object tree (pointer-free Value).
Diagnostic ruleDiagnostic(eve::DiagnosticCode code, RuleId rule, DiagnosticSeverity severity, std::string message)
Build an owning common diagnostic carrying an open editing rule identity.
RuleId diagnosticRule(const Diagnostic &diagnostic)
Return the projected editing rule, or an empty RuleId when absent.
EditorMcpProjector & editorMcpProjector()
Process-wide projector used by EditorAutomationProvider and eve.mcp.attachEditor.
eve::editing::Value EditorValue
Compatibility alias for the UI-independent authoring value tree.
Definition EditorValue.h:8
eve::editing::PlanId PlanId
Definition EditorIds.h:35
eve::editing::SessionId SessionId
Definition EditorIds.h:28
eve::editing::TransactionState TransactionState
eve::editing::CommandId CommandId
Definition EditorIds.h:30
eve::editing::TargetId TargetId
Definition EditorIds.h:29
eve::Diagnostic EditorDiagnostic
eve::editing::RuleId RuleId
Definition EditorIds.h:32
@ Commands
Mode A: keep eve_editor_* with schema enrichment (default).
eve::StatusCode EditorStatus
Definition EditorResult.h:8
eve::editing::Revision Revision
std::string_view statusName(BattleStatus status) noexcept
Return the stable protocol spelling of a battle status.
Presentation and execution metadata for a registered command.
std::unique_ptr< rx::Observable< std::string > > distinct