expose task control and deduplicated operations through MCP

This commit is contained in:
2026-09-29 10:26:19 +01:00
parent c1834bad1f
commit 20bbbd26bd
14 changed files with 775 additions and 12 deletions
@@ -16,6 +16,8 @@ public interface AutomationSession {
/** Internal specialized service work, not a generic MCP shell/tool endpoint. */
OperationHandle<AutomationOutcome> submit(TaskIdentity task, String summary, Callable<AutomationOutcome> work);
void attachRuntime(TaskIdentity task, ManagedHeadlessSession runtime);
/** Called only after shutdown has completed, before artifacts can be rebuilt. */
void detachRuntime(TaskIdentity task, ManagedHeadlessSession runtime);
void markCaptureStale();
/** Cleanup runs after workers stop and before returning manual control. */
void onTaskEnd(TaskIdentity task, Runnable cleanup);
@@ -0,0 +1,21 @@
package p.studio.api.automation;
import java.nio.file.Path;
import java.util.Map;
import java.util.concurrent.CompletionStage;
/** Specialized automation services shared by adapters; never grants human permission. */
public interface TaskTools {
ControlResult acquire(Path root);
CompletionStage<ControlResult> release(Path root, String taskId);
TrackedOperation build(Path root, String taskId, String clientRequestId);
TrackedOperation advance(Path root, String taskId, String clientRequestId, long frames);
TrackedOperation operation(Path root, String taskId, OperationLookup lookup);
boolean cancel(Path root, String taskId, String operationId);
HeadlessReply headless(Path root, String taskId, HeadlessAction action, String buildId, Map<String, Object> input);
enum HeadlessAction { BOOT, RESET, SET_INPUT, CLEAR_INPUT, CAPTURE, STATE, FAULT, SHUTDOWN }
record HeadlessReply(Map<String, Object> values, CanonicalCapture capture) {
public HeadlessReply { values = java.util.Collections.unmodifiableMap(new java.util.LinkedHashMap<>(values)); }
}
}
@@ -6,7 +6,8 @@ import java.util.Objects;
/** An operation outcome is not task authority. Null result means it is not available yet. */
public record TrackedOperation(OperationSnapshot operation, String clientRequestId, Progress progress,
String buildId, ShipperPrepareResult buildResult, AutomationOutcome runtimeResult, AutomationFailure failure) {
String buildId, ShipperPrepareResult buildResult, AutomationOutcome runtimeResult, AutomationFailure failure,
boolean workerTerminated, boolean captureStale) {
public TrackedOperation {
Objects.requireNonNull(operation); Objects.requireNonNull(clientRequestId); Objects.requireNonNull(progress);
if (clientRequestId.isBlank()) throw new IllegalArgumentException("Empty client request identity");