Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
import { useMemo } from "react";
|
|
import type {
|
|
AgentGUIInteractionReadiness,
|
|
AgentGUIInteractionReadinessIdentity,
|
|
AgentGUIInteractionReadinessSource
|
|
} from "../../../types";
|
|
import { useEngineSelector } from "../../../shared/engine/useEngineSelector";
|
|
|
|
const SYNCHRONIZING: AgentGUIInteractionReadiness = {
|
|
status: "blocked",
|
|
reason: "synchronizing"
|
|
};
|
|
|
|
/** Reads one exact Host projection; a supplied-but-incomplete source fails closed. */
|
|
export function readAgentGUIInteractionReadiness(input: {
|
|
identity: AgentGUIInteractionReadinessIdentity;
|
|
source?: AgentGUIInteractionReadinessSource | null;
|
|
}): AgentGUIInteractionReadiness | null {
|
|
if (!input.source) return null;
|
|
return input.source.getInteractionReadiness(input.identity) ?? SYNCHRONIZING;
|
|
}
|
|
|
|
export function useAgentGUIInteractionReadiness(input: {
|
|
identity: AgentGUIInteractionReadinessIdentity | null;
|
|
required?: boolean;
|
|
source?: AgentGUIInteractionReadinessSource | null;
|
|
}): AgentGUIInteractionReadiness | null {
|
|
const binding = useMemo(
|
|
() => ({
|
|
getSnapshot: () =>
|
|
input.identity
|
|
? readAgentGUIInteractionReadiness({
|
|
identity: input.identity,
|
|
source: input.source
|
|
})
|
|
: input.required && input.source
|
|
? SYNCHRONIZING
|
|
: null,
|
|
subscribe: (listener: () => void) =>
|
|
input.source?.subscribe(listener) ?? (() => undefined)
|
|
}),
|
|
[input.identity, input.required, input.source]
|
|
);
|
|
return useEngineSelector(
|
|
binding,
|
|
identityInteractionReadiness,
|
|
interactionReadinessEqual
|
|
);
|
|
}
|
|
|
|
function identityInteractionReadiness(
|
|
readiness: AgentGUIInteractionReadiness | null
|
|
): AgentGUIInteractionReadiness | null {
|
|
return readiness;
|
|
}
|
|
|
|
function interactionReadinessEqual(
|
|
left: AgentGUIInteractionReadiness | null,
|
|
right: AgentGUIInteractionReadiness | null
|
|
): boolean {
|
|
return (
|
|
left?.status === right?.status &&
|
|
(left?.status !== "blocked" ||
|
|
(right?.status === "blocked" && left.reason === right.reason))
|
|
);
|
|
}
|